comonad-0.6.1: Haskell 98 comonads

Portabilityportable
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>

Control.Comonad

Contents

Description

$definition

Synopsis

Comonads

class Functor w => Comonad w whereSource

$definition

Methods

extract :: w a -> aSource

 extract . fmap f = f . extract

duplicate :: w a -> w (w a)Source

 duplicate = extend id
 fmap (fmap f) . duplicate = duplicate . fmap f

extend :: (w a -> b) -> w a -> w bSource

 extend f  = fmap f . duplicate

Instances

(=>>) :: Comonad w => w a -> (w a -> b) -> w bSource

extend with the arguments swapped. Dual to >>= for a Monad.

(<<=) :: Comonad w => (w a -> b) -> w a -> w bSource

extend in operator form

liftW :: Comonad w => (a -> b) -> w a -> w bSource

A suitable default definition for fmap for a Comonad. Promotes a function to a comonad.

 fmap f    = extend (f . extract)

wfix :: Comonad w => w (w a -> a) -> aSource

Comonadic fixed point

Cokleisli Arrows

newtype Cokleisli w a b Source

The Cokleisli Arrows of a given Comonad

Constructors

Cokleisli 

Fields

runCokleisli :: w a -> b
 

Cokleisli composition

(=>=) :: Comonad w => (w a -> b) -> (w b -> c) -> w a -> cSource

Left-to-right Cokleisli composition

(=<=) :: Comonad w => (w b -> c) -> (w a -> b) -> w a -> cSource

Right-to-left Cokleisli composition