free-5.1.10: Monads for free
Copyright(C) 2008-2013 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
PortabilityMPTCs, fundeps
Safe HaskellSafe
LanguageHaskell2010

Control.Comonad.Trans.Coiter

Description

The coiterative comonad generated by a comonad

Synopsis

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

newtype CoiterT w a Source #

This is the coiterative comonad generated by a comonad

Constructors

CoiterT 

Fields

Instances

Instances details
ComonadHoist CoiterT Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

cohoist :: (Comonad w, Comonad v) => (forall x. w x -> v x) -> CoiterT w a -> CoiterT v a Source #

ComonadTrans CoiterT Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

lower :: Comonad w => CoiterT w a -> w a Source #

ComonadEnv e w => ComonadEnv e (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

ask :: CoiterT w a -> e Source #

ComonadStore s w => ComonadStore s (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

pos :: CoiterT w a -> s Source #

peek :: s -> CoiterT w a -> a Source #

peeks :: (s -> s) -> CoiterT w a -> a Source #

seek :: s -> CoiterT w a -> CoiterT w a Source #

seeks :: (s -> s) -> CoiterT w a -> CoiterT w a Source #

experiment :: Functor f => (s -> f s) -> CoiterT w a -> f a Source #

ComonadTraced m w => ComonadTraced m (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

trace :: m -> CoiterT w a -> a Source #

Comonad w => ComonadCofree Identity (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

unwrap :: CoiterT w a -> Identity (CoiterT w a) Source #

Foldable w => Foldable (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

fold :: Monoid m => CoiterT w m -> m Source #

foldMap :: Monoid m => (a -> m) -> CoiterT w a -> m Source #

foldMap' :: Monoid m => (a -> m) -> CoiterT w a -> m Source #

foldr :: (a -> b -> b) -> b -> CoiterT w a -> b Source #

foldr' :: (a -> b -> b) -> b -> CoiterT w a -> b Source #

foldl :: (b -> a -> b) -> b -> CoiterT w a -> b Source #

foldl' :: (b -> a -> b) -> b -> CoiterT w a -> b Source #

foldr1 :: (a -> a -> a) -> CoiterT w a -> a Source #

foldl1 :: (a -> a -> a) -> CoiterT w a -> a Source #

toList :: CoiterT w a -> [a] Source #

null :: CoiterT w a -> Bool Source #

length :: CoiterT w a -> Int Source #

elem :: Eq a => a -> CoiterT w a -> Bool Source #

maximum :: Ord a => CoiterT w a -> a Source #

minimum :: Ord a => CoiterT w a -> a Source #

sum :: Num a => CoiterT w a -> a Source #

product :: Num a => CoiterT w a -> a Source #

Eq1 w => Eq1 (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

liftEq :: (a -> b -> Bool) -> CoiterT w a -> CoiterT w b -> Bool Source #

Ord1 w => Ord1 (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

liftCompare :: (a -> b -> Ordering) -> CoiterT w a -> CoiterT w b -> Ordering Source #

Read1 w => Read1 (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (CoiterT w a) Source #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [CoiterT w a] Source #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (CoiterT w a) Source #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [CoiterT w a] Source #

Show1 w => Show1 (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> CoiterT w a -> ShowS Source #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [CoiterT w a] -> ShowS Source #

Traversable w => Traversable (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

traverse :: Applicative f => (a -> f b) -> CoiterT w a -> f (CoiterT w b) Source #

sequenceA :: Applicative f => CoiterT w (f a) -> f (CoiterT w a) Source #

mapM :: Monad m => (a -> m b) -> CoiterT w a -> m (CoiterT w b) Source #

sequence :: Monad m => CoiterT w (m a) -> m (CoiterT w a) Source #

Functor w => Functor (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

fmap :: (a -> b) -> CoiterT w a -> CoiterT w b Source #

(<$) :: a -> CoiterT w b -> CoiterT w a Source #

Comonad w => Comonad (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

extract :: CoiterT w a -> a Source #

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

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

(Typeable w, Typeable a, Data (w (a, CoiterT w a)), Data a) => Data (CoiterT w a) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CoiterT w a -> c (CoiterT w a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CoiterT w a) Source #

toConstr :: CoiterT w a -> Constr Source #

dataTypeOf :: CoiterT w a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (CoiterT w a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CoiterT w a)) Source #

gmapT :: (forall b. Data b => b -> b) -> CoiterT w a -> CoiterT w a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CoiterT w a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CoiterT w a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CoiterT w a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CoiterT w a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CoiterT w a -> m (CoiterT w a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CoiterT w a -> m (CoiterT w a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CoiterT w a -> m (CoiterT w a) Source #

(Read1 w, Read a) => Read (CoiterT w a) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

(Show1 w, Show a) => Show (CoiterT w a) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

showsPrec :: Int -> CoiterT w a -> ShowS Source #

show :: CoiterT w a -> String Source #

showList :: [CoiterT w a] -> ShowS Source #

(Eq1 w, Eq a) => Eq (CoiterT w a) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

(==) :: CoiterT w a -> CoiterT w a -> Bool Source #

(/=) :: CoiterT w a -> CoiterT w a -> Bool Source #

(Ord1 w, Ord a) => Ord (CoiterT w a) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

compare :: CoiterT w a -> CoiterT w a -> Ordering Source #

(<) :: CoiterT w a -> CoiterT w a -> Bool Source #

(<=) :: CoiterT w a -> CoiterT w a -> Bool Source #

(>) :: CoiterT w a -> CoiterT w a -> Bool Source #

(>=) :: CoiterT w a -> CoiterT w a -> Bool Source #

max :: CoiterT w a -> CoiterT w a -> CoiterT w a Source #

min :: CoiterT w a -> CoiterT w a -> CoiterT w a Source #

The coiterative comonad

type Coiter = CoiterT Identity Source #

The coiterative comonad

coiter :: a -> Coiter a -> Coiter a Source #

Prepends a result to a coiterative computation.

runCoiter . uncurry coiter == id

runCoiter :: Coiter a -> (a, Coiter a) Source #

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 Source #

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 Source #

Allows you to peel a layer off a cofree comonad.

Methods

unwrap :: w a -> f (w a) Source #

Remove a layer.

Instances

Instances details
ComonadCofree Maybe NonEmpty Source # 
Instance details

Defined in Control.Comonad.Cofree.Class

Methods

unwrap :: NonEmpty a -> Maybe (NonEmpty a) Source #

ComonadCofree [] Tree Source # 
Instance details

Defined in Control.Comonad.Cofree.Class

Methods

unwrap :: Tree a -> [Tree a] Source #

Comonad w => ComonadCofree Identity (CoiterT w) Source # 
Instance details

Defined in Control.Comonad.Trans.Coiter

Methods

unwrap :: CoiterT w a -> Identity (CoiterT w a) Source #

Functor f => ComonadCofree f (Cofree f) Source # 
Instance details

Defined in Control.Comonad.Cofree

Methods

unwrap :: Cofree f a -> f (Cofree f a) Source #

ComonadCofree f w => ComonadCofree f (EnvT e w) Source # 
Instance details

Defined in Control.Comonad.Cofree.Class

Methods

unwrap :: EnvT e w a -> f (EnvT e w a) Source #

ComonadCofree f w => ComonadCofree f (StoreT s w) Source # 
Instance details

Defined in Control.Comonad.Cofree.Class

Methods

unwrap :: StoreT s w a -> f (StoreT s w a) Source #

(ComonadCofree f w, Monoid m) => ComonadCofree f (TracedT m w) Source # 
Instance details

Defined in Control.Comonad.Cofree.Class

Methods

unwrap :: TracedT m w a -> f (TracedT m w a) Source #

(Functor f, Comonad w) => ComonadCofree f (CofreeT f w) Source # 
Instance details

Defined in Control.Comonad.Trans.Cofree

Methods

unwrap :: CofreeT f w a -> f (CofreeT f w a) Source #

ComonadCofree f w => ComonadCofree f (IdentityT w) Source # 
Instance details

Defined in Control.Comonad.Cofree.Class

Methods

unwrap :: IdentityT w a -> f (IdentityT w a) Source #

ComonadCofree (Const b :: Type -> Type) ((,) b) Source # 
Instance details

Defined in Control.Comonad.Cofree.Class

Methods

unwrap :: (b, a) -> Const b (b, a) Source #

Examples