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 cofree comonad transformer
Synopsis
- newtype CofreeT f w a = CofreeT {
- runCofreeT :: w (CofreeF f a (CofreeT f w a))
- type Cofree f = CofreeT f Identity
- cofree :: CofreeF f a (Cofree f a) -> Cofree f a
- runCofree :: Cofree f a -> CofreeF f a (Cofree f a)
- data CofreeF f a b = a :< (f b)
- class (Functor f, Comonad w) => ComonadCofree f w | w -> f where
- headF :: CofreeF f a b -> a
- tailF :: CofreeF f a b -> f b
- transCofreeT :: (Functor g, Comonad w) => (forall x. f x -> g x) -> CofreeT f w a -> CofreeT g w a
- coiterT :: (Functor f, Comonad w) => (w a -> f (w a)) -> w a -> CofreeT f w a
Documentation
newtype CofreeT f w a Source #
This is a cofree comonad of some functor f
, with a comonad w
threaded through it at each level.
CofreeT | |
|
Instances
(Functor f, ComonadEnv e w) => ComonadEnv e (CofreeT f w) Source # | |
Defined in Control.Comonad.Trans.Cofree | |
(Functor f, Comonad w) => ComonadCofree f (CofreeT f w) Source # | |
ComonadTrans (CofreeT f) Source # | |
Defined in Control.Comonad.Trans.Cofree | |
Functor f => ComonadHoist (CofreeT f) Source # | |
Alternative f => MonadTrans (CofreeT f) Source # | |
Defined in Control.Comonad.Trans.Cofree | |
(Alternative f, Monad w) => Monad (CofreeT f w) Source # | |
(Functor f, Functor w) => Functor (CofreeT f w) Source # | |
(Alternative f, Applicative w) => Applicative (CofreeT f w) Source # | |
Defined in Control.Comonad.Trans.Cofree | |
(Foldable f, Foldable w) => Foldable (CofreeT f w) Source # | |
Defined in Control.Comonad.Trans.Cofree fold :: Monoid m => CofreeT f w m -> m # foldMap :: Monoid m => (a -> m) -> CofreeT f w a -> m # foldr :: (a -> b -> b) -> b -> CofreeT f w a -> b # foldr' :: (a -> b -> b) -> b -> CofreeT f w a -> b # foldl :: (b -> a -> b) -> b -> CofreeT f w a -> b # foldl' :: (b -> a -> b) -> b -> CofreeT f w a -> b # foldr1 :: (a -> a -> a) -> CofreeT f w a -> a # foldl1 :: (a -> a -> a) -> CofreeT f w a -> a # toList :: CofreeT f w a -> [a] # null :: CofreeT f w a -> Bool # length :: CofreeT f w a -> Int # elem :: Eq a => a -> CofreeT f w a -> Bool # maximum :: Ord a => CofreeT f w a -> a # minimum :: Ord a => CofreeT f w a -> a # | |
(Traversable f, Traversable w) => Traversable (CofreeT f w) Source # | |
Defined in Control.Comonad.Trans.Cofree | |
(Alternative f, MonadZip f, MonadZip m) => MonadZip (CofreeT f m) Source # | |
(Functor f, Comonad w) => Comonad (CofreeT f w) Source # | |
Eq (w (CofreeF f a (CofreeT f w a))) => Eq (CofreeT f w a) Source # | |
(Typeable f, Typeable w, Typeable a, Data (w (CofreeF f a (CofreeT f w a))), Data a) => Data (CofreeT f w a) Source # | |
Defined in Control.Comonad.Trans.Cofree gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CofreeT f w a -> c (CofreeT f w a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CofreeT f w a) # toConstr :: CofreeT f w a -> Constr # dataTypeOf :: CofreeT f w a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (CofreeT f w a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CofreeT f w a)) # gmapT :: (forall b. Data b => b -> b) -> CofreeT f w a -> CofreeT f w a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CofreeT f w a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CofreeT f w a -> r # gmapQ :: (forall d. Data d => d -> u) -> CofreeT f w a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CofreeT f w a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CofreeT f w a -> m (CofreeT f w a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CofreeT f w a -> m (CofreeT f w a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CofreeT f w a -> m (CofreeT f w a) # | |
Ord (w (CofreeF f a (CofreeT f w a))) => Ord (CofreeT f w a) Source # | |
Defined in Control.Comonad.Trans.Cofree compare :: CofreeT f w a -> CofreeT f w a -> Ordering # (<) :: CofreeT f w a -> CofreeT f w a -> Bool # (<=) :: CofreeT f w a -> CofreeT f w a -> Bool # (>) :: CofreeT f w a -> CofreeT f w a -> Bool # (>=) :: CofreeT f w a -> CofreeT f w a -> Bool # | |
Read (w (CofreeF f a (CofreeT f w a))) => Read (CofreeT f w a) Source # | |
Show (w (CofreeF f a (CofreeT f w a))) => Show (CofreeT f w a) Source # | |
cofree :: CofreeF f a (Cofree f a) -> Cofree f a Source #
Wrap another layer around a cofree comonad value.
cofree
is a right inverse of runCofree
.
runCofree . cofree == id
runCofree :: Cofree f a -> CofreeF f a (Cofree f a) Source #
Unpeel the first layer off a cofree comonad value.
runCofree
is a right inverse of cofree
.
cofree . runCofree == id
This is the base functor of the cofree comonad transformer.
a :< (f b) infixr 5 |
Instances
Traversable f => Bitraversable (CofreeF f) Source # | |
Defined in Control.Comonad.Trans.Cofree bitraverse :: Applicative f0 => (a -> f0 c) -> (b -> f0 d) -> CofreeF f a b -> f0 (CofreeF f c d) # | |
Foldable f => Bifoldable (CofreeF f) Source # | |
Functor f => Bifunctor (CofreeF f) Source # | |
Generic1 (CofreeF f a :: * -> *) Source # | |
Functor f => Functor (CofreeF f a) Source # | |
Foldable f => Foldable (CofreeF f a) Source # | |
Defined in Control.Comonad.Trans.Cofree fold :: Monoid m => CofreeF f a m -> m # foldMap :: Monoid m => (a0 -> m) -> CofreeF f a a0 -> m # foldr :: (a0 -> b -> b) -> b -> CofreeF f a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> CofreeF f a a0 -> b # foldl :: (b -> a0 -> b) -> b -> CofreeF f a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> CofreeF f a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> CofreeF f a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> CofreeF f a a0 -> a0 # toList :: CofreeF f a a0 -> [a0] # null :: CofreeF f a a0 -> Bool # length :: CofreeF f a a0 -> Int # elem :: Eq a0 => a0 -> CofreeF f a a0 -> Bool # maximum :: Ord a0 => CofreeF f a a0 -> a0 # minimum :: Ord a0 => CofreeF f a a0 -> a0 # | |
Traversable f => Traversable (CofreeF f a) Source # | |
Defined in Control.Comonad.Trans.Cofree | |
(Eq a, Eq (f b)) => Eq (CofreeF f a b) Source # | |
(Typeable f, Typeable a, Typeable b, Data a, Data (f b), Data b) => Data (CofreeF f a b) Source # | |
Defined in Control.Comonad.Trans.Cofree gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> CofreeF f a b -> c (CofreeF f a b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CofreeF f a b) # toConstr :: CofreeF f a b -> Constr # dataTypeOf :: CofreeF f a b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (CofreeF f a b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CofreeF f a b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> CofreeF f a b -> CofreeF f a b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CofreeF f a b -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CofreeF f a b -> r # gmapQ :: (forall d. Data d => d -> u) -> CofreeF f a b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CofreeF f a b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CofreeF f a b -> m (CofreeF f a b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CofreeF f a b -> m (CofreeF f a b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CofreeF f a b -> m (CofreeF f a b) # | |
(Ord a, Ord (f b)) => Ord (CofreeF f a b) Source # | |
Defined in Control.Comonad.Trans.Cofree compare :: CofreeF f a b -> CofreeF f a b -> Ordering # (<) :: CofreeF f a b -> CofreeF f a b -> Bool # (<=) :: CofreeF f a b -> CofreeF f a b -> Bool # (>) :: CofreeF f a b -> CofreeF f a b -> Bool # (>=) :: CofreeF f a b -> CofreeF f a b -> Bool # | |
(Read a, Read (f b)) => Read (CofreeF f a b) Source # | |
(Show a, Show (f b)) => Show (CofreeF f a b) Source # | |
Generic (CofreeF f a b) Source # | |
type Rep1 (CofreeF f a :: * -> *) Source # | |
Defined in Control.Comonad.Trans.Cofree type Rep1 (CofreeF f a :: * -> *) = D1 (MetaData "CofreeF" "Control.Comonad.Trans.Cofree" "free-5.1-5DqT5y8WzG7CmjGqAVwxRB" False) (C1 (MetaCons ":<" (InfixI RightAssociative 5) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 f))) | |
type Rep (CofreeF f a b) Source # | |
Defined in Control.Comonad.Trans.Cofree type Rep (CofreeF f a b) = D1 (MetaData "CofreeF" "Control.Comonad.Trans.Cofree" "free-5.1-5DqT5y8WzG7CmjGqAVwxRB" False) (C1 (MetaCons ":<" (InfixI RightAssociative 5) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f b)))) |
class (Functor f, Comonad w) => ComonadCofree f w | w -> f where Source #
Allows you to peel a layer off a cofree comonad.
Instances
ComonadCofree [] Tree Source # | |
ComonadCofree Maybe NonEmpty Source # | |
Functor f => ComonadCofree f (Cofree f) Source # | |
Comonad w => ComonadCofree Identity (CoiterT w) Source # | |
(ComonadCofree f w, Monoid m) => ComonadCofree f (TracedT m w) Source # | |
ComonadCofree f w => ComonadCofree f (StoreT s w) Source # | |
ComonadCofree f w => ComonadCofree f (EnvT e w) Source # | |
ComonadCofree f w => ComonadCofree f (IdentityT w) Source # | |
(Functor f, Comonad w) => ComonadCofree f (CofreeT f w) Source # | |
ComonadCofree (Const b :: * -> *) ((,) b) Source # | |
Defined in Control.Comonad.Cofree.Class |