Copyright | (C) 2008-2013 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | MPTCs, fundeps |
Safe Haskell | Safe |
Language | Haskell2010 |
The coiterative comonad generated by a comonad
Synopsis
- newtype CoiterT w a = CoiterT {
- runCoiterT :: w (a, CoiterT w a)
- type Coiter = CoiterT Identity
- coiter :: a -> Coiter a -> Coiter a
- runCoiter :: Coiter a -> (a, Coiter a)
- unfold :: Comonad w => (w a -> a) -> w a -> CoiterT w a
- class (Functor f, Comonad w) => ComonadCofree f w | w -> f where
- unwrap :: w a -> f (w a)
Documentation
Coiterative comonads represent non-terminating, productive computations.
They are the dual notion of iterative monads. While iterative computations produce no values or eventually terminate with one, coiterative computations constantly produce values and they never terminate.
It's simpler form, Coiter
, is an infinite stream of data. CoiterT
extends this so that each step of the computation can be performed in
a comonadic context.
The coiterative comonad transformer
This is the coiterative comonad generated by a comonad
CoiterT | |
|
Instances
ComonadTrans CoiterT # | |
Defined in Control.Comonad.Trans.Coiter | |
ComonadHoist CoiterT # | |
ComonadEnv e w => ComonadEnv e (CoiterT w) # | |
Defined in Control.Comonad.Trans.Coiter | |
ComonadStore s w => ComonadStore s (CoiterT w) # | |
ComonadTraced m w => ComonadTraced m (CoiterT w) # | |
Defined in Control.Comonad.Trans.Coiter | |
Comonad w => ComonadCofree Identity (CoiterT w) # | |
Functor w => Functor (CoiterT w) # | |
Foldable w => Foldable (CoiterT w) # | |
Defined in Control.Comonad.Trans.Coiter fold :: Monoid m => CoiterT w m -> m # foldMap :: Monoid m => (a -> m) -> CoiterT w a -> m # foldMap' :: Monoid m => (a -> m) -> CoiterT w a -> m # foldr :: (a -> b -> b) -> b -> CoiterT w a -> b # foldr' :: (a -> b -> b) -> b -> CoiterT w a -> b # foldl :: (b -> a -> b) -> b -> CoiterT w a -> b # foldl' :: (b -> a -> b) -> b -> CoiterT w a -> b # foldr1 :: (a -> a -> a) -> CoiterT w a -> a # foldl1 :: (a -> a -> a) -> CoiterT w a -> a # toList :: CoiterT w a -> [a] # length :: CoiterT w a -> Int # elem :: Eq a => a -> CoiterT w a -> Bool # maximum :: Ord a => CoiterT w a -> a # minimum :: Ord a => CoiterT w a -> a # | |
Traversable w => Traversable (CoiterT w) # | |
Defined in Control.Comonad.Trans.Coiter | |
Eq1 w => Eq1 (CoiterT w) # | |
Ord1 w => Ord1 (CoiterT w) # | |
Defined in Control.Comonad.Trans.Coiter | |
Read1 w => Read1 (CoiterT w) # | |
Defined in Control.Comonad.Trans.Coiter | |
Show1 w => Show1 (CoiterT w) # | |
Comonad w => Comonad (CoiterT w) # | |
(Eq1 w, Eq a) => Eq (CoiterT w a) # | |
(Typeable w, Typeable a, Data (w (a, CoiterT w a)), Data a) => Data (CoiterT w a) # | |
Defined in Control.Comonad.Trans.Coiter gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CoiterT w a -> c (CoiterT w a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CoiterT w a) # toConstr :: CoiterT w a -> Constr # dataTypeOf :: CoiterT w a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (CoiterT w a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CoiterT w a)) # gmapT :: (forall b. Data b => b -> b) -> CoiterT w a -> CoiterT w a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CoiterT w a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CoiterT w a -> r # gmapQ :: (forall d. Data d => d -> u) -> CoiterT w a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CoiterT w a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CoiterT w a -> m (CoiterT w a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CoiterT w a -> m (CoiterT w a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CoiterT w a -> m (CoiterT w a) # | |
(Ord1 w, Ord a) => Ord (CoiterT w a) # | |
Defined in Control.Comonad.Trans.Coiter | |
(Read1 w, Read a) => Read (CoiterT w a) # | |
(Show1 w, Show a) => Show (CoiterT w a) # | |
The coiterative comonad
coiter :: a -> Coiter a -> Coiter a #
Prepends a result to a coiterative computation.
runCoiter . uncurry coiter == id
runCoiter :: Coiter a -> (a, Coiter a) #
Extracts the first result from a coiterative computation.
uncurry coiter . runCoiter == id
Generating coiterative comonads
unfold :: Comonad w => (w a -> a) -> w a -> CoiterT w a #
Unfold a CoiterT
comonad transformer from a cokleisli arrow and an initial comonadic seed.
Cofree comonads
class (Functor f, Comonad w) => ComonadCofree f w | w -> f where #
Allows you to peel a layer off a cofree comonad.
Instances
ComonadCofree [] Tree # | |
Defined in Control.Comonad.Cofree.Class | |
ComonadCofree Maybe NonEmpty # | |
Functor f => ComonadCofree f (Cofree f) # | |
Defined in Control.Comonad.Cofree | |
Comonad w => ComonadCofree Identity (CoiterT w) # | |
(ComonadCofree f w, Monoid m) => ComonadCofree f (TracedT m w) # | |
Defined in Control.Comonad.Cofree.Class | |
ComonadCofree f w => ComonadCofree f (StoreT s w) # | |
Defined in Control.Comonad.Cofree.Class | |
ComonadCofree f w => ComonadCofree f (EnvT e w) # | |
Defined in Control.Comonad.Cofree.Class | |
ComonadCofree f w => ComonadCofree f (IdentityT w) # | |
Defined in Control.Comonad.Cofree.Class | |
(Functor f, Comonad w) => ComonadCofree f (CofreeT f w) # | |
Defined in Control.Comonad.Trans.Cofree | |
ComonadCofree (Const b :: Type -> Type) ((,) b) # | |
Defined in Control.Comonad.Cofree.Class |