planet-mitchell-0.1.0: Planet Mitchell

Contents

Synopsis

class Functor w => Comonad (w :: * -> *) where #

There are two ways to define a comonad:

I. Provide definitions for extract and extend satisfying these laws:

extend extract      = id
extract . extend f  = f
extend f . extend g = extend (f . extend g)


In this case, you may simply set fmap = liftW.

These laws are directly analogous to the laws for monads and perhaps can be made clearer by viewing them as laws stating that Cokleisli composition must be associative, and has extract for a unit:

f =>= extract   = f
extract =>= f   = f
(f =>= g) =>= h = f =>= (g =>= h)


II. Alternately, you may choose to provide definitions for fmap, extract, and duplicate satisfying these laws:

extract . duplicate      = id
fmap extract . duplicate = id
duplicate . duplicate    = fmap duplicate . duplicate


In this case you may not rely on the ability to define fmap in terms of liftW.

You may of course, choose to define both duplicate and extend. In that case you must also satisfy these laws:

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


These are the default definitions of extend and duplicate and the definition of liftW respectively.

Minimal complete definition

Methods

extract :: w a -> a #

extract . fmap f = f . extract


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

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


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

extend f = fmap f . duplicate

Instances

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

Comonadic fixed point à la David Menendez

cfix :: Comonad w => (w a -> a) -> w a #

Comonadic fixed point à la Dominic Orchard

kfix :: ComonadApply w => w (w a -> a) -> w a #

Comonadic fixed point à la Kenneth Foner:

This is the evaluate function from his "Getting a Quick Fix on Comonads" talk.

(=>=) :: Comonad w => (w a -> b) -> (w b -> c) -> w a -> c infixr 1 #

Left-to-right Cokleisli composition

(=<=) :: Comonad w => (w b -> c) -> (w a -> b) -> w a -> c infixr 1 #

Right-to-left Cokleisli composition

(<<=) :: Comonad w => (w a -> b) -> w a -> w b infixr 1 #

extend in operator form

(=>>) :: Comonad w => w a -> (w a -> b) -> w b infixl 1 #

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

class Comonad w => ComonadApply (w :: * -> *) where #

ComonadApply is to Comonad like Applicative is to Monad.

Mathematically, it is a strong lax symmetric semi-monoidal comonad on the category Hask of Haskell types. That it to say that w is a strong lax symmetric semi-monoidal functor on Hask, where both extract and duplicate are symmetric monoidal natural transformations.

Laws:

(.) <$> u <@> v <@> w = u <@> (v <@> w) extract (p <@> q) = extract p (extract q) duplicate (p <@> q) = (<@>) <$> duplicate p <@> duplicate q


If our type is both a ComonadApply and Applicative we further require

(<*>) = (<@>)


Finally, if you choose to define (<@) and (@>), the results of your definitions should match the following laws:

a @> b = const id <$> a <@> b a <@ b = const <$> a <@> b


Methods

(<@>) :: w (a -> b) -> w a -> w b infixl 4 #

(@>) :: w a -> w b -> w b infixl 4 #

(<@) :: w a -> w b -> w a infixl 4 #

Instances
 Instance detailsDefined in Control.Comonad Methods(<@>) :: Identity (a -> b) -> Identity a -> Identity b #(@>) :: Identity a -> Identity b -> Identity b #(<@) :: Identity a -> Identity b -> Identity a # Instance detailsDefined in Control.Comonad Methods(<@>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b #(@>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #(<@) :: NonEmpty a -> NonEmpty b -> NonEmpty a # Instance detailsDefined in Control.Comonad Methods(<@>) :: Tree (a -> b) -> Tree a -> Tree b #(@>) :: Tree a -> Tree b -> Tree b #(<@) :: Tree a -> Tree b -> Tree a # Instance detailsDefined in Numeric.Log Methods(<@>) :: Log (a -> b) -> Log a -> Log b #(@>) :: Log a -> Log b -> Log b #(<@) :: Log a -> Log b -> Log a # Semigroup m => ComonadApply ((,) m) Instance detailsDefined in Control.Comonad Methods(<@>) :: (m, a -> b) -> (m, a) -> (m, b) #(@>) :: (m, a) -> (m, b) -> (m, b) #(<@) :: (m, a) -> (m, b) -> (m, a) # Instance detailsDefined in Control.Comonad.Cofree Methods(<@>) :: Cofree f (a -> b) -> Cofree f a -> Cofree f b #(@>) :: Cofree f a -> Cofree f b -> Cofree f b #(<@) :: Cofree f a -> Cofree f b -> Cofree f a # Instance detailsDefined in Control.Lens.Reified Methods(<@>) :: ReifiedGetter s (a -> b) -> ReifiedGetter s a -> ReifiedGetter s b #(@>) :: ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s b #(<@) :: ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s a # Instance detailsDefined in Control.Comonad Methods(<@>) :: IdentityT w (a -> b) -> IdentityT w a -> IdentityT w b #(@>) :: IdentityT w a -> IdentityT w b -> IdentityT w b #(<@) :: IdentityT w a -> IdentityT w b -> IdentityT w a # (ComonadApply f, ComonadApply g) => ComonadApply (Day f g) Instance detailsDefined in Data.Functor.Day Methods(<@>) :: Day f g (a -> b) -> Day f g a -> Day f g b #(@>) :: Day f g a -> Day f g b -> Day f g b #(<@) :: Day f g a -> Day f g b -> Day f g a # Monoid m => ComonadApply ((->) m :: * -> *) Instance detailsDefined in Control.Comonad Methods(<@>) :: (m -> a -> b) -> (m -> a) -> m -> b #(@>) :: (m -> a) -> (m -> b) -> m -> b #(<@) :: (m -> a) -> (m -> b) -> m -> a # (a ~ b, Conjoined p) => ComonadApply (Bazaar p a b) Instance detailsDefined in Control.Lens.Internal.Bazaar Methods(<@>) :: Bazaar p a b (a0 -> b0) -> Bazaar p a b a0 -> Bazaar p a b b0 #(@>) :: Bazaar p a b a0 -> Bazaar p a b b0 -> Bazaar p a b b0 #(<@) :: Bazaar p a b a0 -> Bazaar p a b b0 -> Bazaar p a b a0 # (a ~ b, Conjoined p) => ComonadApply (Bazaar1 p a b) Instance detailsDefined in Control.Lens.Internal.Bazaar Methods(<@>) :: Bazaar1 p a b (a0 -> b0) -> Bazaar1 p a b a0 -> Bazaar1 p a b b0 #(@>) :: Bazaar1 p a b a0 -> Bazaar1 p a b b0 -> Bazaar1 p a b b0 #(<@) :: Bazaar1 p a b a0 -> Bazaar1 p a b b0 -> Bazaar1 p a b a0 # (a ~ b, Conjoined p) => ComonadApply (BazaarT p g a b) Instance detailsDefined in Control.Lens.Internal.Bazaar Methods(<@>) :: BazaarT p g a b (a0 -> b0) -> BazaarT p g a b a0 -> BazaarT p g a b b0 #(@>) :: BazaarT p g a b a0 -> BazaarT p g a b b0 -> BazaarT p g a b b0 #(<@) :: BazaarT p g a b a0 -> BazaarT p g a b b0 -> BazaarT p g a b a0 # (a ~ b, Conjoined p) => ComonadApply (BazaarT1 p g a b) Instance detailsDefined in Control.Lens.Internal.Bazaar Methods(<@>) :: BazaarT1 p g a b (a0 -> b0) -> BazaarT1 p g a b a0 -> BazaarT1 p g a b b0 #(@>) :: BazaarT1 p g a b a0 -> BazaarT1 p g a b b0 -> BazaarT1 p g a b b0 #(<@) :: BazaarT1 p g a b a0 -> BazaarT1 p g a b b0 -> BazaarT1 p g a b a0 #

(<@@>) :: ComonadApply w => w a -> w (a -> b) -> w b infixl 4 #

A variant of <@> with the arguments reversed.

liftW2 :: ComonadApply w => (a -> b -> c) -> w a -> w b -> w c #

Lift a binary function into a Comonad with zipping

liftW3 :: ComonadApply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d #

Lift a ternary function into a Comonad with zipping

Newtypes

newtype Cokleisli (w :: k -> *) (a :: k) b :: forall k. (k -> *) -> k -> * -> * #

The Cokleisli Arrows of a given Comonad

Constructors

 Cokleisli FieldsrunCokleisli :: w a -> b
Instances
 Comonad w => Category (Cokleisli w :: * -> * -> *) Instance detailsDefined in Control.Comonad Methodsid :: Cokleisli w a a #(.) :: Cokleisli w b c -> Cokleisli w a b -> Cokleisli w a c # Extend w => Semigroupoid (Cokleisli w :: * -> * -> *) Instance detailsDefined in Data.Semigroupoid Methodso :: Cokleisli w j k1 -> Cokleisli w i j -> Cokleisli w i k1 # Comonad w => Arrow (Cokleisli w) Instance detailsDefined in Control.Comonad Methodsarr :: (b -> c) -> Cokleisli w b c #first :: Cokleisli w b c -> Cokleisli w (b, d) (c, d) #second :: Cokleisli w b c -> Cokleisli w (d, b) (d, c) #(***) :: Cokleisli w b c -> Cokleisli w b' c' -> Cokleisli w (b, b') (c, c') #(&&&) :: Cokleisli w b c -> Cokleisli w b c' -> Cokleisli w b (c, c') # Comonad w => ArrowChoice (Cokleisli w) Instance detailsDefined in Control.Comonad Methodsleft :: Cokleisli w b c -> Cokleisli w (Either b d) (Either c d) #right :: Cokleisli w b c -> Cokleisli w (Either d b) (Either d c) #(+++) :: Cokleisli w b c -> Cokleisli w b' c' -> Cokleisli w (Either b b') (Either c c') #(|||) :: Cokleisli w b d -> Cokleisli w c d -> Cokleisli w (Either b c) d # Comonad w => ArrowApply (Cokleisli w) Instance detailsDefined in Control.Comonad Methodsapp :: Cokleisli w (Cokleisli w b c, b) c # Instance detailsDefined in Control.Comonad Methodsloop :: Cokleisli w (b, d) (c, d) -> Cokleisli w b c # Functor w => Profunctor (Cokleisli w) Instance detailsDefined in Data.Profunctor.Unsafe Methodsdimap :: (a -> b) -> (c -> d) -> Cokleisli w b c -> Cokleisli w a d #lmap :: (a -> b) -> Cokleisli w b c -> Cokleisli w a c #rmap :: (b -> c) -> Cokleisli w a b -> Cokleisli w a c #(#.) :: Coercible c b => (b -> c) -> Cokleisli w a b -> Cokleisli w a c #(.#) :: Coercible b a => Cokleisli w b c -> (a -> b) -> Cokleisli w a c # Instance detailsDefined in Data.Profunctor.Rep Associated Typestype Corep (Cokleisli w) :: * -> * # Methodscotabulate :: (Corep (Cokleisli w) d -> c) -> Cokleisli w d c # Comonad w => Choice (Cokleisli w) extract approximates costrength Instance detailsDefined in Data.Profunctor.Choice Methodsleft' :: Cokleisli w a b -> Cokleisli w (Either a c) (Either b c) #right' :: Cokleisli w a b -> Cokleisli w (Either c a) (Either c b) # Functor f => Closed (Cokleisli f) Instance detailsDefined in Data.Profunctor.Closed Methodsclosed :: Cokleisli f a b -> Cokleisli f (x -> a) (x -> b) # Functor f => Costrong (Cokleisli f) Instance detailsDefined in Data.Profunctor.Strong Methodsunfirst :: Cokleisli f (a, d) (b, d) -> Cokleisli f a b #unsecond :: Cokleisli f (d, a) (d, b) -> Cokleisli f a b # Monad (Cokleisli w a) Instance detailsDefined in Control.Comonad Methods(>>=) :: Cokleisli w a a0 -> (a0 -> Cokleisli w a b) -> Cokleisli w a b #(>>) :: Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a b #return :: a0 -> Cokleisli w a a0 #fail :: String -> Cokleisli w a a0 # Functor (Cokleisli w a) Instance detailsDefined in Control.Comonad Methodsfmap :: (a0 -> b) -> Cokleisli w a a0 -> Cokleisli w a b #(<\$) :: a0 -> Cokleisli w a b -> Cokleisli w a a0 # Applicative (Cokleisli w a) Instance detailsDefined in Control.Comonad Methodspure :: a0 -> Cokleisli w a a0 #(<*>) :: Cokleisli w a (a0 -> b) -> Cokleisli w a a0 -> Cokleisli w a b #liftA2 :: (a0 -> b -> c) -> Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a c #(*>) :: Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a b #(<*) :: Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a a0 # Apply (Cokleisli w a) Instance detailsDefined in Data.Functor.Bind.Class Methods(<.>) :: Cokleisli w a (a0 -> b) -> Cokleisli w a a0 -> Cokleisli w a b #(.>) :: Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a b #(<.) :: Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a a0 #liftF2 :: (a0 -> b -> c) -> Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a c # Pointed (Cokleisli w a) Instance detailsDefined in Data.Pointed Methodspoint :: a0 -> Cokleisli w a a0 # type Corep (Cokleisli w) Instance detailsDefined in Data.Profunctor.Rep type Corep (Cokleisli w) = w