-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell 98 comonad transformers -- -- Haskell 98 comonad transformers @package comonad-transformers @version 0.3 module Control.Comonad.Trans.Identity -- | The trivial monad transformer, which maps a monad to an equivalent -- monad. newtype IdentityT m :: (* -> *) a :: (* -> *) -> * -> * IdentityT :: m a -> IdentityT a runIdentityT :: IdentityT a -> m a module Control.Comonad.Trans.Class class ComonadTrans t lower :: (ComonadTrans t, Comonad w) => t w a -> w a instance ComonadTrans IdentityT -- | Discont is the Density comonad of a constant functor, just as Cont is -- a Codensity monad of a constant functor. -- -- Note that Discont and Context are isomorphic, but DiscontT and -- ContextT are not. module Control.Comonad.Trans.Discont.Lazy type Discont s = DiscontT s Identity discont :: (s -> a) -> s -> Discont s a runDiscont :: Discont s a -> (s -> a, s) data DiscontT s w a DiscontT :: (w s -> a) -> (w s) -> DiscontT s w a runDiscontT :: DiscontT s w a -> (w s -> a, w s) callCV :: DiscontT s w (DiscontT s w (DiscontT s w a -> a) -> b) -> b instance ComonadTrans (DiscontT s) instance Comonad w => Comonad (DiscontT s w) instance Functor w => Functor (DiscontT s w) -- | The discontinuation comonad transformer. This version is lazy; for a -- strict version, see Control.Comonad.Trans.Discont.Strict, which -- has the same interface. module Control.Comonad.Trans.Discont -- | Discont is the Density comonad of a constant functor, just as Cont is -- a Codensity monad of a constant functor. -- -- Note that Discont and Context are isomorphic, but DiscontT and -- ContextT are not. module Control.Comonad.Trans.Discont.Strict type Discont s = DiscontT s Identity discont :: (s -> a) -> s -> Discont s a runDiscont :: Discont s a -> (s -> a, s) data DiscontT s w a DiscontT :: (w s -> a) -> (w s) -> DiscontT s w a runDiscontT :: DiscontT s w a -> (w s -> a, w s) callCV :: DiscontT s w (DiscontT s w (DiscontT s w a -> a) -> b) -> b instance ComonadTrans (DiscontT s) instance Comonad w => Comonad (DiscontT s w) instance Functor w => Functor (DiscontT s w) module Control.Comonad.Hoist.Class class ComonadHoist t cohoist :: (ComonadHoist t, Comonad w) => t w a -> t Identity a instance ComonadHoist IdentityT -- | The environment comonad transformer (aka coreader). This adds an extra -- value that can be accessed in the environment. -- -- Left adjoint to the reader comonad. module Control.Comonad.Trans.Env.Lazy type Env e = EnvT e Identity env :: e -> a -> Env e a runEnv :: Env e a -> (e, a) data EnvT e w a runEnvT :: EnvT e w a -> (e, w a) ask :: EnvT e w a -> e asks :: (e -> f) -> EnvT e w a -> f local :: (e -> e) -> EnvT e w a -> EnvT e w a instance ComonadHoist (EnvT e) instance ComonadTrans (EnvT e) instance Comonad w => Comonad (EnvT e w) instance Functor w => Functor (EnvT e w) -- | The environment comonad transformer (aka coreader). This version is -- lazy; for a strict version, see -- Control.Comonad.Trans.Env.Strict, which has the same interface. module Control.Comonad.Trans.Env -- | The environment comonad transformer (aka coreader). This adds an extra -- value that can be accessed in the environment. -- -- Left adjoint to the reader comonad. module Control.Comonad.Trans.Env.Strict type Env e = EnvT e Identity env :: e -> a -> Env e a runEnv :: Env e a -> (e, a) data EnvT e w a EnvT :: e -> (w a) -> EnvT e w a runEnvT :: EnvT e w a -> (e, w a) ask :: EnvT e w a -> e asks :: (e -> f) -> EnvT e w a -> f local :: (e -> e) -> EnvT e w a -> EnvT e w a instance ComonadHoist (EnvT e) instance ComonadTrans (EnvT e) instance Comonad w => Comonad (EnvT e w) instance Functor w => Functor (EnvT e w) -- | The lazy store (state-in-context/costate) comonad transformer is -- subject to the laws: -- --
--   x = put (get x) x
--   y = get (put y x)
--   put y x = put y (put z x)
--   
-- -- Thanks go to Russell O'Connor and Daniel Peebles for their help -- formulating and proving the laws for this comonad transformer. module Control.Comonad.Trans.Store.Lazy type Store s = StoreT s Identity store :: (s -> a) -> s -> Store s a runStore :: Store s a -> (s -> a, s) data StoreT s w a StoreT :: (w (s -> a)) -> s -> StoreT s w a runStoreT :: StoreT s w a -> (w (s -> a), s) get :: StoreT s w a -> s put :: Comonad w => s -> StoreT s w a -> a modify :: Comonad w => (s -> s) -> StoreT s w a -> a experiment :: (Comonad w, Functor f) => f (s -> s) -> StoreT s w a -> f a instance ComonadHoist (StoreT s) instance ComonadTrans (StoreT s) instance Comonad w => Comonad (StoreT s w) instance Functor w => Functor (StoreT s w) -- | The store comonad transformer (aka costate). This version is lazy; for -- a strict version, see Control.Comonad.Trans.Store.Strict, which -- has the same interface. module Control.Comonad.Trans.Store -- | The strict store (state-in-context/costate) comonad transformer is -- subject to the laws: -- --
--   x = put (get x) x
--   y = get (put y x)
--   put y x = put y (put z x)
--   
-- -- Thanks go to Russell O'Connor and Daniel Peebles for their help -- formulating and proving the laws for this comonad transformer. module Control.Comonad.Trans.Store.Strict type Store s = StoreT s Identity store :: (s -> a) -> s -> Store s a runStore :: Store s a -> (s -> a, s) data StoreT s w a StoreT :: (w (s -> a)) -> s -> StoreT s w a runStoreT :: StoreT s w a -> (w (s -> a), s) get :: StoreT s w a -> s put :: Comonad w => s -> StoreT s w a -> a modify :: Comonad w => (s -> s) -> StoreT s w a -> a experiment :: (Comonad w, Functor f) => f (s -> s) -> StoreT s w a -> f a instance ComonadHoist (StoreT s) instance ComonadTrans (StoreT s) instance Comonad w => Comonad (StoreT s w) instance Functor w => Functor (StoreT s w) -- | The trace comonad transformer (aka the cowriter or exponential comonad -- transformer). module Control.Comonad.Trans.Traced type Traced m = TracedT m Identity traced :: (m -> a) -> Traced m a runTraced :: Monoid m => Traced m a -> m -> a newtype TracedT m w a TracedT :: w (m -> a) -> TracedT m w a runTracedT :: TracedT m w a -> w (m -> a) trace :: (Comonad w, Monoid m) => m -> TracedT m w a -> a listen :: Functor w => TracedT m w a -> TracedT m w (a, m) listens :: Functor w => (m -> b) -> TracedT m w a -> TracedT m w (a, b) censor :: Functor w => (m -> m) -> TracedT m w a -> TracedT m w a instance Monoid m => ComonadHoist (TracedT m) instance Monoid m => ComonadTrans (TracedT m) instance (Comonad w, Monoid m) => Comonad (TracedT m w) instance Functor w => Functor (TracedT m w) -- | The f-branching stream comonad, aka the cofree comonad for a Functor -- f. -- -- Provided here as a comonad-transformer version of the 'ListT done -- right' monad transformer. module Control.Comonad.Trans.Stream type Stream f = StreamT f Identity stream :: a -> f (Stream f a) -> Stream f a runStream :: Stream f a -> (a, f (Stream f a)) data StreamT f w a StreamT :: w (a, f (StreamT f w a)) -> StreamT f w a runStreamT :: StreamT f w a -> w (a, f (StreamT f w a)) tails :: Comonad w => StreamT f w a -> f (StreamT f w a) unfolds :: Functor f => (a -> (b, f a)) -> a -> Stream f b unfoldsW :: (Comonad w, Functor f) => (w a -> (b, f a)) -> w a -> StreamT f w b instance (Traversable w, Traversable f) => Traversable (StreamT f w) instance (Foldable w, Foldable f) => Foldable (StreamT f w) instance Functor f => ComonadHoist (StreamT f) instance Functor f => ComonadTrans (StreamT f) instance (Comonad w, Functor f) => Comonad (StreamT f w) instance (Functor w, Functor f) => Functor (StreamT f w)