-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Explicit Sharing of Monadic Effects
--
-- This package implements a monad transformer for sharing monadic
-- effects.
@package explicit-sharing
@version 0.3.1
module Control.Monad.Sharing
-- | Interface of monads that support explicit sharing.
class Sharing m
share :: (Sharing m, Trans m a a) => m a -> m (m a)
-- | Interface to transform nested monadic data types. The provided |
-- function trans is supposed to map the given function on every
-- | monadic argument. The result of trans may be of the same
-- type | as the argument but can also be of a different type, e.g. to |
-- convert a value with nested monadic arguments to a corresponding |
-- value without.
class Trans m a b
trans :: (Trans m a b) => (forall c d. (Trans m c d) => m c -> m (m d)) -> a -> m b
-- | Lifts all monadic effects in nested monadic values to the top | level.
-- If m is a monad for non-determinism and the argument a | data
-- structure with nested non-determinism then the result | corresponds to
-- the normal form of the argument.
eval :: (Monad m, Trans m a b) => a -> m b
-- | Data type for lists where both the head and tail are monadic.
data List m a
Nil :: List m a
Cons :: (m a) -> (m (List m a)) -> List m a
-- | The empty monadic list.
nil :: (Monad m) => m (List m a)
-- | Constructs a non-empty monadic list.
cons :: (Monad m) => m a -> m (List m a) -> m (List m a)
-- | Checks if monadic list is empty.
isEmpty :: (Monad m) => m (List m a) -> m Bool
-- | Yields the head of a monadic list. Relies on MonadPlus
-- instance | to provide a failing implementation of fail.
first :: (MonadPlus m) => m (List m a) -> m a
-- | Yields the tail of a monadic list. Relies on MonadPlus
-- instance | to provide a failing implementation of fail.
rest :: (MonadPlus m) => m (List m a) -> m (List m a)
instance (Monad m, Trans m a a) => Trans m (List m a) [a]
instance (Monad m, Trans m a a) => Trans m (List m a) (List m a)
instance (Monad m, Trans m a a) => Trans m [m a] [a]
instance (Monad m, Trans m a a) => Trans m [m a] [m a]
instance (Monad m) => Trans m Double Double
instance (Monad m) => Trans m Float Float
instance (Monad m) => Trans m Char Char
instance (Monad m) => Trans m Int Int
instance (Monad m) => Trans m Bool Bool
module Control.Monad.Sharing.Lazy
-- | Continuation-based, store-passing implementation of explicit |
-- sharing. It is an inlined version of ContT (ReaderT Store m)
-- | where the result type of continuations is polymorphic.
data Lazy m a
-- | Lifts all monadic effects to the top-level and unwraps the monad |
-- transformer for explicit sharing.
evalLazy :: (Monad m, Trans (Lazy m) a b) => Lazy m a -> m b
instance (Monad m) => Sharing (Lazy m)
instance (MonadPlus m) => MonadPlus (Lazy m)
instance (Monad m) => Monad (Lazy m)