Control.Comonad
Description
(C) 2004 Dave Menendez License : BSD-style (see the file LICENSE)
Maintainer : Edward Kmett [email protected] Stability : experimental Portability : portable
This module declares the Comonad
class
- module Control.Functor.Pointed
- class Copointed w => Comonad w where
- liftW :: Comonad w => (a -> b) -> w a -> w b
- (=>>) :: Comonad w => w a -> (w a -> b) -> w b
- (.>>) :: Comonad w => w a -> b -> w b
- liftCtx :: Comonad w => (a -> b) -> w a -> b
- mapW :: Comonad w => (w a -> b) -> w [a] -> [b]
- parallelW :: Comonad w => w [a] -> [w a]
- unfoldW :: Comonad w => (w b -> (a, b)) -> w b -> [a]
- sequenceW :: Comonad w => [w a -> b] -> w a -> [b]
Documentation
module Control.Functor.Pointed
class Copointed w => Comonad w whereSource
There are two ways to define a comonad:
I. Provide definitions for fmap
, extract
, and duplicate
satisfying these laws:
extract . duplicate == id fmap extract . duplicate == id duplicate . duplicate == fmap duplicate . duplicate
II. Provide definitions for extract
and extend
satisfying these laws:
extend extract == id extract . extend f == f extend f . extend g == extend (f . extend g)
(fmap
cannot be defaulted, but a comonad which defines
extend
may simply set fmap
equal to liftW
.)
A comonad providing definitions for extend
and duplicate
,
must also satisfy these laws:
extend f == fmap f . duplicate duplicate == extend id fmap f == extend (f . duplicate)
(The first two are the defaults for extend
and duplicate
,
and the third is the definition of liftW
.)
Instances
Comonad Identity | |
Comonad Supply | |
Monoid m => Comonad ((->) m) | |
Comonad ((,) e) | |
Comonad (Context s) | |
Monoid m => Comonad (Exp m) | |
Ix i => Comonad (Pointer i) | |
Comonad (Coreader r) | |
(Bifunctor f Hask Hask Hask, PComonad f) => Comonad (Fix f) | |
Comonad (Density f) | |
ComonadCoideal w => Comonad (Coideal w) | |
Comonad w => Comonad (CoYoneda w) | |
Comonad f => Comonad (Yoneda f) | |
Comonad w => Comonad (ContextT b w) | |
Comonad w => Comonad (CoreaderT w b) | |
Adjunction f g => Comonad (ACompF f g) | |
(Comonad f, Comonad g, Distributes f g) => Comonad (DistCompF f g) | |
(Copointed f, Comonad w, PreUnfold f w) => Comonad (PreCompF f w) | |
(Comonad w, Copointed f, PostUnfold w f) => Comonad (PostCompF w f) |