Skip to content

Instantly share code, notes, and snippets.

View kcsongor's full-sized avatar
🤡
':<>:

Csongor Kiss kcsongor

🤡
':<>:
View GitHub Profile
@kcsongor
kcsongor / bs.sh
Last active September 16, 2015 13:16 — forked from jonathanlking/bs.sh
Web Economy Bullshit Generator ported to bash to help git commits
#!/usr/bin/env bash
# This is a bash port of the Web Economy Bullshit Generator
# http://www.dack.com/web/bullshit.html
# Now you don't have to worry about commit messages!
ARRAY1=("implement" "utilize" "integrate" "streamline" "optimize" "evolve" "transform" "embrace"
"enable" "orchestrate" "leverage" "reinvent" "aggregate" "architect" "enhance" "incentivize" "morph" "empower"
"envisioneer" "monetize" "harness" "facilitate" "seize" "disintermediate" "synergize" "strategize" "deploy"
"brand" "grow" "target" "syndicate" "synthesize" "deliver" "mesh" "incubate" "engage" "maximize" "benchmark"
@kcsongor
kcsongor / printf.hs
Last active March 30, 2016 19:25
typesafe polymorphic printf in haskell (using Text.PrettyPrinter as a backend)
-- TODO: add some comments
-- TODO: add more formatting options
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
@kcsongor
kcsongor / printf2.hs
Last active March 30, 2016 21:21
type safe printf using Text.Printf as a backend (type-level magic)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE LambdaCase #-}
@kcsongor
kcsongor / RE-type.hs
Last active October 10, 2017 20:15
Toying with type-level regular expressions
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE UndecidableInstances #-}
module Regex where
data RE
= forall (a :: *). Term a
module Main where
import Data.Functor.Foldable
import Data.Maybe
g :: (Ord a, Num a) => (a, [[a]]) -> Prim [Maybe a] (a, [[a]])
g (n, xs)
| n `elem` concatMap (take 1) xs'
= Cons Nothing (n + 2, xs')
| otherwise

Keybase proof

I hereby claim:

  • I am kcsongor on github.
  • I am kcsongor (https://keybase.io/kcsongor) on keybase.
  • I have a public key whose fingerprint is 94BA 971A 46EB E234 C000 F91A C76B BDA2 4458 BE78

To claim this, I am signing this object:

@kcsongor
kcsongor / asd.hs
Created December 17, 2016 02:43
fixonacci
fix f = let x = f x in x
fib = fix (\f -> 0 : 1 : zw (+) f (tail f))
where
zw = fix (\zw' -> \f xs ys -> case xs of
(x : xs') -> case ys of
(y : ys') -> f x y : zw' f xs' ys'
_ -> []
_ -> [])
@kcsongor
kcsongor / generic-encode.hs
Created January 23, 2017 17:45
Generic encoding
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
@kcsongor
kcsongor / Tuples.hs
Created June 13, 2017 10:38
Extensible tuples
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE TypeOperators #-}
object Main {
/*
* First thing first, we turn on a ("advanced") language feature via
* `import scala.language.higherKinds`
*
* This is so that we can express higher-kinded types (HKTs) in generic
* parameters. Comes in handy for `Functor`, as all functors are HKTs, and
* also for `Fix`, for similar reasons.
*