| Portability | rank-2 types |
|---|---|
| Stability | experimental |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
Control.Comonad.Cofree
Description
- newtype BiffB p f g a b = BiffB {
- runBiffB :: p (f a) (g b)
- newtype FixB s a = InB {}
- class Bifunctor f => PCopointed f where
- pextract :: f a c -> a
- class PCopointed f => PComonad f where
- pextend :: (f b c -> a) -> f b c -> f a c
- newtype Identity a = Identity {
- runIdentity :: a
- type CofreeB f a b = BiffB (,) Identity f a b
- type Cofree f a = FixB (BiffB (,) Identity f) a
- outCofree :: Cofree f a -> f (Cofree f a)
- runCofree :: Cofree f a -> (a, f (Cofree f a))
- anaCofree :: Functor f => (a -> c) -> (a -> f a) -> a -> Cofree f c
- cofree :: a -> f (Cofree f a) -> Cofree f a
Documentation
newtype BiffB p f g a b Source
Instances
| (Functor f, Bifunctor p, Functor g) => Bifunctor (BiffB p f g) | |
| Functor f => PCopointed (BiffB (,) Identity f) | |
| Functor f => PPointed (BiffB Either Identity f) | |
| FunctorPlus f => PPointed (BiffB (,) Identity f) | |
| (Functor f, Symmetric p) => Symmetric (BiffB p f f) | |
| (Functor f, Braided p) => Braided (BiffB p f f) | |
| Functor f => PComonad (BiffB (,) Identity f) | |
| Functor f => PApplicative (BiffB Either Identity f) | |
| FunctorPlus f => PApplicative (BiffB (,) Identity f) | |
| Functor f => PMonad (BiffB Either Identity f) | |
| FunctorPlus f => PMonad (BiffB (,) Identity f) | |
| (Bizip p, Zip f, Zip g) => Bizip (BiffB p f g) | |
| (BiZap p q, Zap f g, Zap i j) => BiZap (BiffB p f i) (BiffB q g j) | |
| (Functor f, Bifunctor p, Functor g) => Functor (BiffB p f g a) |
class Bifunctor f => PCopointed f whereSource
Instances
| Functor f => PCopointed (BiffB (,) Identity f) |
class PCopointed f => PComonad f whereSource
newtype Identity a
Identity wrapper. Abstraction for wrapping up a object. If you have an monadic function, say:
example :: Int -> Identity Int example x = return (x*x)
you can "run" it, using
Main> runIdentity (example 42) 1764 :: Int
A typical use of the Identity monad is to derive a monad from a monad transformer.
-- derive theControl.Monad.State.Statemonad using theControl.Monad.State.StateTmonad transformer typeControl.Monad.State.States a =Control.Monad.State.StateTsIdentitya
The label is used in the type definition because it follows
a style of monad definition that explicitly represents monad values as
computations. In this style, a monadic computation is built up using the monadic
operators and then the value of the computation is extracted
using the runIdentityrun****** function.
Because the Identity monad does not do any computation, its definition
is trivial.
For a better example of this style of monad,
see the monad.
Control.Monad.State.State
Constructors
| Identity | |
Fields
| |
Instances
| Monad Identity | |
| Functor Identity | |
| MonadFix Identity | |
| Copointed Identity | |
| Pointed Identity | |
| Comonad Identity | |
| ComonadFix Identity | |
| Cozip Identity | |
| Zip Identity | |
| Zap Identity Identity | |
| Functor f => PCopointed (BiffB (,) Identity f) | |
| Functor f => PPointed (BiffB Either Identity f) | |
| FunctorPlus f => PPointed (BiffB (,) Identity f) | |
| Functor f => PComonad (BiffB (,) Identity f) | |
| Functor f => PApplicative (BiffB Either Identity f) | |
| FunctorPlus f => PApplicative (BiffB (,) Identity f) | |
| Functor f => PMonad (BiffB Either Identity f) | |
| FunctorPlus f => PMonad (BiffB (,) Identity f) |