Created
January 1, 2015 16:32
-
-
Save tel/dcff11ff677dd167b27a to your computer and use it in GitHub Desktop.
Really ugly Het Compose thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE DataKinds #-} | |
module HetComp where | |
type family as ++ bs :: [k] where | |
'[] ++ bs = bs | |
(a ': as) ++ bs = a ': (as ++ bs) | |
data Comp :: [*] -> * -> * where | |
Inj :: (a -> b) -> Comp '[a] b | |
Id :: Comp '[a] a | |
Comp :: Comp as x -> Comp (x ': bs) r -> Comp (as ++ (x ': bs)) r | |
(>>>) :: Comp as x -> Comp (x ': bs) r -> Comp (as ++ (x ': bs)) r | |
(>>>) = Comp | |
infixr 9 >>> | |
ex1 :: Comp [Int, Int, Int, Int] Int | |
ex1 = Inj (+1) >>> Inj (+1) >>> Id >>> Inj (+1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment