comonad-transformers-0.6.2: Haskell 98 comonad transformers

MaintainerEdward Kmett <>




The f-branching stream comonad, aka the cofree comonad for a Functor f.

Provided here as a comonad-transformer version of the 'ListT done right' monad transformer.


The Stream comonad

type Stream f = StreamT f IdentitySource

Isomorphic to the definition:

 data Stream f a = a :< f (Stream f a)

stream :: a -> f (Stream f a) -> Stream f aSource

cons onto an f-branching stream

runStream :: Stream f a -> (a, f (Stream f a))Source

uncons from an f-branching stream

unfolds :: Functor f => (a -> (b, f a)) -> a -> Stream f bSource

unfold a stream from a seed.

The Stream comonad transformer

data StreamT f w a Source

The f-branching stream comonad transformer is a comonadic version of the "ListT done Right" monad transformer. You can extract the underlying comonadic value by using lower or runStream




runStreamT :: w (a, f (StreamT f w a))


Functor f => ComonadTrans (StreamT f) 
Functor f => ComonadHoist (StreamT f) 
(Functor w, Functor f) => Functor (StreamT f w) 
(Typeable1 f, Typeable1 w) => Typeable1 (StreamT f w) 
(Foldable w, Foldable f) => Foldable (StreamT f w) 
(Traversable w, Traversable f) => Traversable (StreamT f w) 
(Comonad w, Functor f) => Comonad (StreamT f w) 
(ComonadApply w, FunctorApply f) => ComonadApply (StreamT f w) 
(ComonadApply w, FunctorApply f) => FunctorApply (StreamT f w) 
(Typeable1 f, Typeable1 w, Data (w (a, f (StreamT f w a))), Data (a, f (StreamT f w a)), Data (f (StreamT f w a)), Data a) => Data (StreamT f w a) 
(Typeable1 f, Typeable1 w, Typeable a) => Typeable (StreamT f w a) 


tails :: Comonad w => StreamT f w a -> f (StreamT f w a)Source

unfoldsW :: (Comonad w, Functor f) => (w a -> (b, f a)) -> w a -> StreamT f w bSource