free-functors-0.8.3: Free functors, adjoint to functors that forget class constraints.

License BSD-style (see the file LICENSE) sjoerd@w3future.com experimental non-portable Safe Haskell2010

Data.Functor.Cofree

Contents

Description

A cofree functor is right adjoint to a forgetful functor. In this package the forgetful functor forgets class constraints.

Synopsis

# Documentation

data Cofree c b where Source #

The cofree functor for constraint c.

Constructors

 Cofree :: c a => (a -> b) -> a -> Cofree c b

Instances

 (ForallF * * c Identity, ForallF * * c (Compose * * (Cofree c) (Cofree c))) => Monad (Cofree c) Source # Methods(>>=) :: Cofree c a -> (a -> Cofree c b) -> Cofree c b #(>>) :: Cofree c a -> Cofree c b -> Cofree c b #return :: a -> Cofree c a #fail :: String -> Cofree c a # Source # Methodsfmap :: (a -> b) -> Cofree c a -> Cofree c b #(<\$) :: a -> Cofree c b -> Cofree c a # (ForallF * * c Identity, ForallF * * c (Compose * * (Cofree c) (Cofree c))) => Applicative (Cofree c) Source # Methodspure :: a -> Cofree c a #(<*>) :: Cofree c (a -> b) -> Cofree c a -> Cofree c b #liftA2 :: (a -> b -> c) -> Cofree c a -> Cofree c b -> Cofree c c #(*>) :: Cofree c a -> Cofree c b -> Cofree c b #(<*) :: Cofree c a -> Cofree c b -> Cofree c a # Source # Methodsextract :: Cofree c a -> a #duplicate :: Cofree c a -> Cofree c (Cofree c a) #extend :: (Cofree c a -> b) -> Cofree c a -> Cofree c b #

counit :: Cofree c b -> b Source #

leftAdjunct :: c a => (a -> b) -> a -> Cofree c b Source #

leftAdjunctF :: ForallF c f => (f a -> b) -> f a -> Cofree c b Source #

unit :: c b => b -> Cofree c b Source #

unit = leftAdjunct id

rightAdjunct :: (a -> Cofree c b) -> a -> b Source #

rightAdjunct f = counit . f

convert :: (c (w a), Comonad w) => w a -> Cofree c a Source #

# Products

type Product c m n = Cofree c (m, n) Source #

product :: c a => (a -> m) -> (a -> n) -> a -> Product c m n Source #

outL :: Product c m n -> m Source #

outR :: Product c m n -> n Source #

terminal :: c a => a -> TerminalObject c Source #