| 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 |
Control.Comonad.Trans.Cofree
Description
The cofree comonad transformer
Synopsis
- newtype CofreeT (f :: Type -> Type) (w :: Type -> Type) a = CofreeT {
- runCofreeT :: w (CofreeF f a (CofreeT f w a))
- type Cofree (f :: Type -> Type) = CofreeT f Identity
- cofree :: forall (f :: Type -> Type) a. CofreeF f a (Cofree f a) -> Cofree f a
- runCofree :: forall (f :: Type -> Type) a. Cofree f a -> CofreeF f a (Cofree f a)
- data CofreeF (f :: Type -> Type) a b = a :< (f b)
- class (Functor f, Comonad w) => ComonadCofree (f :: Type -> Type) (w :: Type -> Type) | w -> f where
- unwrap :: w a -> f (w a)
- headF :: forall (f :: Type -> Type) a b. CofreeF f a b -> a
- tailF :: CofreeF f a b -> f b
- transCofreeT :: forall g (w :: Type -> Type) f a. (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 :: Type -> Type) (w :: Type -> Type) a Source #
This is a cofree comonad of some functor f, with a comonad w threaded through it at each level.
Constructors
| CofreeT | |
Fields
| |
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 # | |
| Functor f => ComonadHoist (CofreeT f) Source # | |
| ComonadTrans (CofreeT f) Source # | |
| Alternative f => MonadTrans (CofreeT f) Source # | |
| (Alternative f, MonadZip f, MonadZip m) => MonadZip (CofreeT f m) Source # | |
| (Functor f, Comonad w) => Comonad (CofreeT f w) Source # | |
| (Alternative f, Applicative w) => Applicative (CofreeT f w) Source # | |
Defined in Control.Comonad.Trans.Cofree Methods pure :: a -> CofreeT f w a Source # (<*>) :: CofreeT f w (a -> b) -> CofreeT f w a -> CofreeT f w b Source # liftA2 :: (a -> b -> c) -> CofreeT f w a -> CofreeT f w b -> CofreeT f w c Source # (*>) :: CofreeT f w a -> CofreeT f w b -> CofreeT f w b Source # (<*) :: CofreeT f w a -> CofreeT f w b -> CofreeT f w a Source # | |
| (Functor f, Functor w) => Functor (CofreeT f w) Source # | |
| (Alternative f, Monad w) => Monad (CofreeT f w) Source # | |
| (Foldable f, Foldable w) => Foldable (CofreeT f w) Source # | |
Defined in Control.Comonad.Trans.Cofree Methods fold :: Monoid m => CofreeT f w m -> m Source # foldMap :: Monoid m => (a -> m) -> CofreeT f w a -> m Source # foldMap' :: Monoid m => (a -> m) -> CofreeT f w a -> m Source # foldr :: (a -> b -> b) -> b -> CofreeT f w a -> b Source # foldr' :: (a -> b -> b) -> b -> CofreeT f w a -> b Source # foldl :: (b -> a -> b) -> b -> CofreeT f w a -> b Source # foldl' :: (b -> a -> b) -> b -> CofreeT f w a -> b Source # foldr1 :: (a -> a -> a) -> CofreeT f w a -> a Source # foldl1 :: (a -> a -> a) -> CofreeT f w a -> a Source # toList :: CofreeT f w a -> [a] Source # null :: CofreeT f w a -> Bool Source # length :: CofreeT f w a -> Int Source # elem :: Eq a => a -> CofreeT f w a -> Bool Source # maximum :: Ord a => CofreeT f w a -> a Source # minimum :: Ord a => CofreeT f w a -> a Source # | |
| (Traversable f, Traversable w) => Traversable (CofreeT f w) Source # | |
Defined in Control.Comonad.Trans.Cofree Methods traverse :: Applicative f0 => (a -> f0 b) -> CofreeT f w a -> f0 (CofreeT f w b) Source # sequenceA :: Applicative f0 => CofreeT f w (f0 a) -> f0 (CofreeT f w a) Source # mapM :: Monad m => (a -> m b) -> CofreeT f w a -> m (CofreeT f w b) Source # sequence :: Monad m => CofreeT f w (m a) -> m (CofreeT f w a) Source # | |
| (Typeable f, Typeable w, Data (w (CofreeF f a (CofreeT f w a))), Data a) => Data (CofreeT f w a) Source # | |
Defined in Control.Comonad.Trans.Cofree Methods 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) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CofreeT f w a) Source # toConstr :: CofreeT f w a -> Constr Source # dataTypeOf :: CofreeT f w a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (CofreeT f w a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CofreeT f w a)) Source # gmapT :: (forall b. Data b => b -> b) -> CofreeT f w a -> CofreeT f w a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CofreeT f w a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CofreeT f w a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> CofreeT f w a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> CofreeT f w a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CofreeT f w a -> m (CofreeT f w a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CofreeT f w a -> m (CofreeT f w a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CofreeT f w a -> m (CofreeT f w a) Source # | |
| 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 # | |
| Eq (w (CofreeF f a (CofreeT f w a))) => Eq (CofreeT f w a) Source # | |
| Ord (w (CofreeF f a (CofreeT f w a))) => Ord (CofreeT f w a) Source # | |
Defined in Control.Comonad.Trans.Cofree Methods compare :: CofreeT f w a -> CofreeT f w a -> Ordering Source # (<) :: CofreeT f w a -> CofreeT f w a -> Bool Source # (<=) :: CofreeT f w a -> CofreeT f w a -> Bool Source # (>) :: CofreeT f w a -> CofreeT f w a -> Bool Source # (>=) :: CofreeT f w a -> CofreeT f w a -> Bool Source # max :: CofreeT f w a -> CofreeT f w a -> CofreeT f w a Source # min :: CofreeT f w a -> CofreeT f w a -> CofreeT f w a Source # | |
cofree :: forall (f :: Type -> Type) a. 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 :: forall (f :: Type -> Type) a. 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
data CofreeF (f :: Type -> Type) a b Source #
This is the base functor of the cofree comonad transformer.
Constructors
| a :< (f b) infixr 5 |
Instances
class (Functor f, Comonad w) => ComonadCofree (f :: Type -> Type) (w :: Type -> Type) | w -> f where Source #
Allows you to peel a layer off a cofree comonad.
Instances
| ComonadCofree Maybe NonEmpty Source # | |
| ComonadCofree [] Tree Source # | |
| Comonad w => ComonadCofree Identity (CoiterT w) Source # | |
| Functor f => ComonadCofree f (Cofree f) Source # | |
| ComonadCofree f w => ComonadCofree f (EnvT e w) Source # | |
| ComonadCofree f w => ComonadCofree f (StoreT s w) Source # | |
| (ComonadCofree f w, Monoid m) => ComonadCofree f (TracedT m w) Source # | |
| (Functor f, Comonad w) => ComonadCofree f (CofreeT f w) Source # | |
| ComonadCofree f w => ComonadCofree f (IdentityT w) Source # | |
| ComonadCofree (Const b :: Type -> Type) ((,) b) Source # | |
Defined in Control.Comonad.Cofree.Class | |
headF :: forall (f :: Type -> Type) a b. CofreeF f a b -> a Source #
Extract the head of the base functor