-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Free monads and monad transformers
--   
--   This package provides datatypes to construct Free monads, Free monad
--   transformers, and useful instances. In addition it provides the
--   constructs to avoid quadratic complexity of left associative bind, as
--   explained in:
--   
--   <ul>
--   <li>Janis Voigtlander, <i>Asymptotic Improvement of Computations over
--   Free Monads, MPC'08</i></li>
--   </ul>
@package control-monad-free
@version 0.6.1

module Control.Monad.Free

-- | This type class generalizes over encodings of Free Monads.
class (Functor f, Monad m) => MonadFree f m
free :: MonadFree f m => m a -> m (Either a (f (m a)))
wrap :: MonadFree f m => f (m a) -> m a
data Free f a
Impure :: (f (Free f a)) -> Free f a
Pure :: a -> Free f a
isPure :: Free t1 t -> Bool
isImpure :: Free t1 t -> Bool
foldFree :: Functor f => (a -> b) -> (f b -> b) -> Free f a -> b
evalFree :: (a -> b) -> (f (Free f a) -> b) -> Free f a -> b
mapFree :: (Functor f, Functor g) => (f (Free g a) -> g (Free g a)) -> Free f a -> Free g a
mapFreeM :: (Traversable f, Functor g, Monad m) => (f (Free g a) -> m (g (Free g a))) -> Free f a -> m (Free g a)
mapFreeM' :: (Functor f, Traversable g, Monad m) => (forall a. f a -> m (g a)) -> Free f a -> m (Free g a)
foldFreeM :: (Traversable f, Monad m) => (a -> m b) -> (f b -> m b) -> Free f a -> m b
induce :: (Functor f, Monad m) => (forall a. f a -> m a) -> Free f a -> m a
newtype FreeT f m a
FreeT :: m (Either a (f (FreeT f m a))) -> FreeT f m a
[unFreeT] :: FreeT f m a -> m (Either a (f (FreeT f m a)))
foldFreeT :: (Traversable f, Monad m) => (a -> m b) -> (f b -> m b) -> FreeT f m a -> m b
foldFreeT' :: (Traversable f, Monad m) => (a -> b) -> (f b -> b) -> FreeT f m a -> m b
mapFreeT :: (Functor f, Functor m) => (forall a. m a -> m' a) -> FreeT f m a -> FreeT f m' a
foldFreeA :: (Traversable f, Applicative m) => (a -> m b) -> m (f b -> b) -> Free f a -> m b
mapFreeA :: (Traversable f, Functor g, Applicative m) => m (f (Free g a) -> g (Free g a)) -> Free f a -> m (Free g a)
trans :: MonadFree f m => Free f a -> m a
trans' :: (Functor f, Monad m) => m (Free f a) -> FreeT f m a
untrans :: (Traversable f, Monad m) => FreeT f m a -> m (Free f a)
liftFree :: (Functor f, Monad m) => (a -> Free f b) -> (a -> FreeT f m b)
instance GHC.Generics.Generic (Control.Monad.Free.Free f a)
instance GHC.Base.Functor f => Control.Monad.Free.MonadFree f (Control.Monad.Free.Free f)
instance Prelude.Extras.Eq1 f => Prelude.Extras.Eq1 (Control.Monad.Free.Free f)
instance (GHC.Classes.Eq a, Prelude.Extras.Eq1 f) => GHC.Classes.Eq (Control.Monad.Free.Free f a)
instance Prelude.Extras.Ord1 f => Prelude.Extras.Ord1 (Control.Monad.Free.Free f)
instance (GHC.Classes.Ord a, Prelude.Extras.Ord1 f) => GHC.Classes.Ord (Control.Monad.Free.Free f a)
instance (GHC.Show.Show a, Prelude.Extras.Show1 f) => GHC.Show.Show (Control.Monad.Free.Free f a)
instance GHC.Base.Functor f => GHC.Base.Functor (Control.Monad.Free.Free f)
instance (GHC.Base.Functor f, Data.Foldable.Foldable f) => Data.Foldable.Foldable (Control.Monad.Free.Free f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Free.Free f)
instance GHC.Base.Functor f => GHC.Base.Monad (Control.Monad.Free.Free f)
instance GHC.Base.Functor f => GHC.Base.Applicative (Control.Monad.Free.Free f)
instance (Data.Traversable.Traversable m, Data.Traversable.Traversable f) => Data.Foldable.Foldable (Control.Monad.Free.FreeT f m)
instance (Data.Traversable.Traversable m, Data.Traversable.Traversable f) => Data.Traversable.Traversable (Control.Monad.Free.FreeT f m)
instance (GHC.Base.Functor f, GHC.Base.Functor m) => GHC.Base.Functor (Control.Monad.Free.FreeT f m)
instance (GHC.Base.Functor f, GHC.Base.Functor a, GHC.Base.Monad a) => GHC.Base.Applicative (Control.Monad.Free.FreeT f a)
instance (GHC.Base.Functor f, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Free.FreeT f m)
instance (GHC.Base.Functor f, GHC.Base.Monad m) => Control.Monad.Free.MonadFree f (Control.Monad.Free.FreeT f m)
instance GHC.Base.Functor f => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Free.FreeT f)
instance (GHC.Base.Functor f, GHC.Base.Monad m, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Free.FreeT f m)
instance (GHC.Base.Functor f, GHC.Base.Monad m, GHC.Base.MonadPlus m) => GHC.Base.MonadPlus (Control.Monad.Free.FreeT f m)
instance (GHC.Base.Functor f, GHC.Base.Functor m, GHC.Base.Monad m, GHC.Base.MonadPlus m) => GHC.Base.Alternative (Control.Monad.Free.FreeT f m)


-- | Naive Free monads suffer from a quadratic complexity, as explained in
--   
--   <ul>
--   <li>Janis Voigtlander, <i>Asymptotic Improvement of Computations over
--   Free Monads, MPC'08</i></li>
--   </ul>
--   
--   The solution is to redefine the Free datatype in CPS, similar to what
--   is done in difference lists to solve the problem on quadratic append
--   for lists.
module Control.Monad.Free.Improve
newtype C mu a
C :: (forall b. (a -> mu b) -> mu b) -> C mu a
rep :: Monad mu => mu a -> C mu a
improve :: Monad mu => C mu a -> mu a
instance GHC.Base.Functor (Control.Monad.Free.Improve.C mu)
instance GHC.Base.Monad (Control.Monad.Free.Improve.C mu)
instance GHC.Base.Applicative (Control.Monad.Free.Improve.C mu)
instance GHC.Base.Functor f => Control.Monad.Free.MonadFree f (Control.Monad.Free.Improve.C (Control.Monad.Free.Free f))
instance (GHC.Base.Monad m, GHC.Base.Functor f) => Control.Monad.Free.MonadFree f (Control.Monad.Free.Improve.C (Control.Monad.Free.FreeT f m))
instance GHC.Base.MonadPlus mu => GHC.Base.MonadPlus (Control.Monad.Free.Improve.C mu)
instance GHC.Base.MonadPlus mu => GHC.Base.Alternative (Control.Monad.Free.Improve.C mu)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Free.Improve.C

module Control.Monad.Free.Zip
zipFree :: (Traversable f, Eq (f ()), Monad m) => (Free f a -> Free f b -> m (Free f c)) -> Free f a -> Free f b -> m (Free f c)
zipFree_ :: (Traversable f, Eq (f ()), Monad m) => (Free f a -> Free f b -> m ()) -> Free f a -> Free f b -> m ()
