-- 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.5.1 -- | This library provides type classes for explicit sharing of monadic -- effects. Usually you don't need to import this library as it is -- reexported by the module Control.Monad.Sharing. You may want -- to do so, however, when writing your own implementation of explicit -- sharing. module Control.Monad.Sharing.Classes -- | Interface of monads that support explicit sharing. class Sharing m share :: (Sharing m, Shareable m a) => m a -> m (m a) -- | Interface of shareable nested monadic data types. The provided -- function shareArgs is supposed to map the given function on -- every monadic argument. -- -- We provide instances of the Shareable class for some predefined -- Haskell types. For flat types the function shareArgs just -- returns its argument which has no arguments to which the given -- function could be applied. class Shareable m a shareArgs :: (Shareable m a, Monad n) => (forall b. (Shareable m b) => m b -> n (m b)) -> a -> n a -- | Interface for convertible datatypes. The provided function -- convArgs is supposed to map the given function on every -- argument of the given value and combine the results to give the -- converted value. -- -- We provide instances of the Convertible class for some -- predefined Haskell types. For flat types the function convArgs -- just returns its argument which has no arguments to which the given -- function could be applied. class Convertible m a b convArgs :: (Convertible m a b) => (forall c d. (Convertible m c d) => c -> m d) -> a -> m b -- | Converts a convertible value recursively. convert :: (Convertible m a b) => a -> m b instance (Monad m, Convertible m a b) => Convertible m [m a] [b] instance (Monad m, Convertible m a b) => Convertible m [a] [m b] instance (Monad m) => Convertible m [Char] [Char] instance (Monad m) => Convertible m [Int] [Int] instance (Monad m) => Convertible m [Bool] [Bool] instance (Monad m) => Convertible m Char Char instance (Monad m) => Convertible m Int Int instance (Monad m) => Convertible m Bool Bool instance (Monad m, Shareable m a) => Shareable m [m a] instance (Monad m) => Shareable m [Char] instance (Monad m) => Shareable m [Int] instance (Monad m) => Shareable m [Bool] instance (Monad m) => Shareable m Char instance (Monad m) => Shareable m Int instance (Monad m) => Shareable m Bool -- | This library provides an interface to monads that support explicit -- sharing based on two-level types. This implementation is not as -- efficient as the default implementation but it avoids duplicate -- sharing which can lead to exponential blowup of the threaded heap. module Control.Monad.Sharing.FirstOrder -- | Interface of monads that support explicit sharing. class Sharing m share :: (Sharing m, Shareable m a) => m a -> m (m a) -- | Interface of shareable nested monadic data types. The provided -- function shareArgs is supposed to map the given function on -- every monadic argument. -- -- We provide instances of the Shareable class for some predefined -- Haskell types. For flat types the function shareArgs just -- returns its argument which has no arguments to which the given -- function could be applied. class Shareable m a shareArgs :: (Shareable m a, Monad n) => (forall b. (Shareable m b) => m b -> n (m b)) -> a -> n a -- | Interface for convertible datatypes. The provided function -- convArgs is supposed to map the given function on every -- argument of the given value and combine the results to give the -- converted value. -- -- We provide instances of the Convertible class for some -- predefined Haskell types. For flat types the function convArgs -- just returns its argument which has no arguments to which the given -- function could be applied. class Convertible m a b convArgs :: (Convertible m a b) => (forall c d. (Convertible m c d) => c -> m d) -> a -> m b -- | Converts a convertible value recursively. convert :: (Convertible m a b) => a -> m b -- | Monad transformer that adds explicit sharing capability to every -- monad. data Lazy m a -- | Lifts all monadic effects to the top-level and unwraps the monad -- transformer for explicit sharing. evalLazy :: (Monad m, Shareable (Lazy m) a, Convertible (Lazy m) a b) => Lazy m a -> m b -- | This library provides lists with monadic head and tail as an example -- for nested monadic data that can be used with the combinator -- share for explicit sharing. module Data.Monadic.List -- | 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, Convertible m a b) => Convertible m (List m a) [b] instance (Monad m, Convertible m a b) => Convertible m [a] (List m b) instance (Monad m, Shareable m a) => Shareable m (List m a) -- | This library provides an interface to monads that support explicit -- sharing. A project website with tutorials can be found at -- http://sebfisch.github.com/explicit-sharing. module Control.Monad.Sharing -- | Interface of monads that support explicit sharing. class Sharing m share :: (Sharing m, Shareable m a) => m a -> m (m a) -- | Interface of shareable nested monadic data types. The provided -- function shareArgs is supposed to map the given function on -- every monadic argument. -- -- We provide instances of the Shareable class for some predefined -- Haskell types. For flat types the function shareArgs just -- returns its argument which has no arguments to which the given -- function could be applied. class Shareable m a shareArgs :: (Shareable m a, Monad n) => (forall b. (Shareable m b) => m b -> n (m b)) -> a -> n a -- | Interface for convertible datatypes. The provided function -- convArgs is supposed to map the given function on every -- argument of the given value and combine the results to give the -- converted value. -- -- We provide instances of the Convertible class for some -- predefined Haskell types. For flat types the function convArgs -- just returns its argument which has no arguments to which the given -- function could be applied. class Convertible m a b convArgs :: (Convertible m a b) => (forall c d. (Convertible m c d) => c -> m d) -> a -> m b -- | Converts a convertible value recursively. convert :: (Convertible m a b) => a -> m b -- | 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, Convertible (Lazy m) a b) => Lazy m a -> m b