Skip to content

Instantly share code, notes, and snippets.

View sebastiaanvisser's full-sized avatar

Sebastiaan Visser sebastiaanvisser

View GitHub Profile
@sebastiaanvisser
sebastiaanvisser / gist:309976
Created February 20, 2010 22:57
Structural typing braindump.
{-# LANGUAGE
TypeOperators
, KindSignatures
, TypeFamilies
, EmptyDataDecls
#-}
module StructuralTyping where
-- Type level sum and product that carry around an explicit type environment
-- encoded as a heterogenous list.
module Main where
import Network.C10kServer
import System.IO
main :: IO ()
main =
runC10kServer (\h i -> hPutStrLn h $ "HTTP/1.1 200 Ok\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\n" ++ show i)
C10kConfig
{ initHook = return ()
@sebastiaanvisser
sebastiaanvisser / tyingtheknot.hs
Created December 27, 2010 13:41
Tying the knot with fclabels.
{-# LANGUAGE
TypeOperators
, TemplateHaskell
#-}
module Tie where
import Prelude hiding ((.), id)
import Control.Category
import Data.Record.Label
@sebastiaanvisser
sebastiaanvisser / gist:856679
Created March 5, 2011 20:16
graph fixpoint
> {-# LANGUAGE
> DeriveFunctor
> , DeriveFoldable
> , DeriveTraversable
> , StandaloneDeriving
> , DoRec
> #-}
> module Graph where
> import Control.Applicative
@sebastiaanvisser
sebastiaanvisser / g0.hs
Created September 10, 2012 08:07
Composing algebras.
{-# LANGUAGE
GADTs
, KindSignatures
, RankNTypes
, TupleSections
, TypeOperators
#-}
module Generics.Morphism where
import Control.Arrow
@sebastiaanvisser
sebastiaanvisser / g1.hs
Created May 29, 2013 08:36
Composing algebras using Arrow and Applicative.
{-# LANGUAGE GADTs, TypeOperators, TupleSections #-}
module Generics.Algebra where
import Control.Category
import Control.Arrow
import Control.Applicative
import Prelude hiding ((.), id)
import Generics.Combinator
@sebastiaanvisser
sebastiaanvisser / gist:6397813
Last active December 22, 2015 01:39
Rule domain datatype.
{-# LANGUAGE GADTs #-}
module Test where
type Var = String
type Program = [(String, Expr ())]
data Expr a where
Intro :: (Expr a -> Expr b) -> Expr ()
Apply :: Expr (a -> b) -> Expr a -> Expr b
@sebastiaanvisser
sebastiaanvisser / ConstraintCategory.hs
Last active December 22, 2015 11:18
Introducing type variables in class constraint, using ConstraintKinds.
-- * Introducing type variables in class constraint, using ConstraintKinds.
-- * (Using ghc-7.6.3)
{-# LANGUAGE ConstraintKinds, GADTs, TypeFamilies #-}
module ConstraintCategory where
import GHC.Exts (Constraint)
-- Version of Category that can put constraints on the i/o of the category.
@sebastiaanvisser
sebastiaanvisser / gist:9639321
Created March 19, 2014 10:48
Echo: A small FRP library.
-- | Echo: a small experimental library for functional reactive programming.
{-# LANGUAGE
GADTs
, GeneralizedNewtypeDeriving
, TemplateHaskell
, RecursiveDo
, MagicHash
, UnboxedTuples
#-}
@sebastiaanvisser
sebastiaanvisser / gist:9785886
Created March 26, 2014 15:22
Higher order functor/applicative/foldable/traversable.
{-# LANGUAGE
DeriveFunctor
, GADTs
, GeneralizedNewtypeDeriving
, TypeOperators
, TypeFamilies
, RankNTypes
#-}
module HigherOrder where