module Data.Thrist ( Thrist (..)
, foldThrist
, appendThrist ) where
import Prelude
import Data.Monoid
data Thrist :: (* -> * -> *) -> * -> * -> * where
Nil :: Thrist p a a
Cons :: p a b -> Thrist p b c -> Thrist p a c
foldThrist :: (forall i j k . p i j -> p j k -> p i k) -> p c c -> Thrist p a c -> p a c
foldThrist _ v Nil = v
foldThrist f v (Cons h t) = h `f` (foldThrist f v t)
appendThrist :: forall (p :: * -> * -> *) a b c .
Thrist p a b ->
Thrist p b c ->
Thrist p a c
appendThrist Nil a = a
appendThrist (Cons b r) a = Cons b (appendThrist r a)
instance Monoid (Thrist p a a) where
mempty = Nil
mappend = appendThrist