free-functors-1.2.1: Free functors, adjoint to functors that forget class constraints.
LicenseBSD-style (see the file LICENSE)
Maintainersjoerd@w3future.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

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

Instances details
(forall x. c (Identity x), forall x. c (Compose (Cofree c) (Cofree c) x)) => Monad (Cofree c) Source # 
Instance details

Defined in Data.Functor.Cofree

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 #

Functor (Cofree c) Source # 
Instance details

Defined in Data.Functor.Cofree

Methods

fmap :: (a -> b) -> Cofree c a -> Cofree c b #

(<$) :: a -> Cofree c b -> Cofree c a #

(forall x. c (Identity x), forall x. c (Compose (Cofree c) (Cofree c) x)) => Applicative (Cofree c) Source # 
Instance details

Defined in Data.Functor.Cofree

Methods

pure :: a -> Cofree c a #

(<*>) :: Cofree c (a -> b) -> Cofree c a -> Cofree c b #

liftA2 :: (a -> b -> c0) -> Cofree c a -> Cofree c b -> Cofree c c0 #

(*>) :: Cofree c a -> Cofree c b -> Cofree c b #

(<*) :: Cofree c a -> Cofree c b -> Cofree c a #

Comonad (Cofree c) Source # 
Instance details

Defined in Data.Functor.Cofree

Methods

extract :: Cofree c a -> a

duplicate :: Cofree c a -> Cofree c (Cofree c a)

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

deriveCofreeInstance :: Name -> Q [Dec] Source #

Derive the instance of Cofree c a for the class c.

counit :: Cofree c b -> b Source #

leftAdjunct :: c a => (a -> b) -> 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 #