Quick actions

cmd+k|ctrl+k

Navigation

Languages

Type Aligned List of Func

Snippet info

Language

Haskell

Visibility

public

Author

homam

Created

2016-10-02T08:52:14Z

Updated

2016-11-20T10:12:52Z

{-# LANGUAGE GADTs, KindSignatures #-}

data TAList :: (* -> * -> *) -> * -> * -> * where
  Nil   :: TAList c x x
  (:::) :: c x y -> TAList c y z -> TAList c x z

infixr 5 :::

newtype Func a b = Func { unFunc :: a -> b }

foldTAList :: a -> TAList Func a b -> b
foldTAList acc Nil = acc
foldTAList acc (h ::: t) = foldTAList (unFunc h acc) t

half x = fromIntegral x / 2 :: Rational
oneThird x = fromRational x / 3 :: Double


flow :: TAList Func Int String
flow  = Func half ::: Func oneThird ::: Func show ::: Nil

main = print $ foldTAList 12 flow
INFO