-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Computational Effects
--
-- Control.Effects is a library for programming with effects, like in the
-- the Eff language by Andrej Bauer and Matija Pretnar. Effects can be
-- used instead of monad transformers.
--
-- See the home page for some example code.
@package effects
@version 0.2.3
module Control.Effects
-- | with takes a handler and creates a new effect instance. The
-- Effect is passed on to a function which can use it to do
-- operations with it.
with :: Monad m => Handler e r m a -> (Effect e m -> Layer e m a) -> m r
-- | Unwrap the result of the top-level effect.
run :: Base Pure a -> a
-- | A Handler e r m a is a handler of effects with type
-- e. The ret field provides a function to lift pure
-- values into the effect. The fin field provides a function to
-- extract a final value of type r from the effect. The
-- parameter m should normally be left polymorphic, it's the
-- monad that handles the other effects.
data Handler e r m a
Handler :: (a -> m e) -> (e -> m r) -> Handler e r m a
[ret] :: Handler e r m a -> a -> m e
[fin] :: Handler e r m a -> e -> m r
-- | operation takes an effect identifier generated by with
-- and a function which takes a continuation as parameter. The result is
-- auto-lifted so it can be used inside any other effect.
operation :: AutoLift e m n => Effect e m -> ((a -> m e) -> m e) -> n a
-- | Unwrap the result of a computation using a base monad.
runBase :: Base m a -> m a
-- | base takes a computation in the base monad and auto-lifts it
-- so it can be used inside any effect.
base :: AutoLiftBase m n => m a -> n a
-- | Layer e m is a monad that adds an effect e to the
-- underlying monad m. (It is the continuation monad transformer
-- with a friendlier name.)
newtype Layer e m a
Layer :: ((a -> m e) -> m e) -> Layer e m a
[runLayer] :: Layer e m a -> (a -> m e) -> m e
-- | Base m is a newtype wrapper around a monadic computation.
newtype Base m a
Base :: (m a) -> Base m a
-- | Pure is the identity monad and is used when no other base
-- monad is needed.
newtype Pure a
Pure :: a -> Pure a
-- | Effect e m is a proxy for the type checker to be able to work
-- with multiple effects at the same time.
data Effect e (m :: * -> *)
class (Applicative m, Applicative n, Monad m, Monad n) => AutoLift e m n
class (Applicative m, Applicative n, Monad m, Monad n) => AutoLiftBase m n
instance GHC.Base.Functor (Control.Effects.Layer e m)
instance GHC.Base.Applicative (Control.Effects.Layer e m)
instance (GHC.Base.Monoid e, GHC.Base.Applicative m) => GHC.Base.Alternative (Control.Effects.Layer e m)
instance GHC.Base.Monad (Control.Effects.Layer e m)
instance (GHC.Base.Monoid e, GHC.Base.Applicative m) => GHC.Base.MonadPlus (Control.Effects.Layer e m)
instance GHC.Base.Functor Control.Effects.Pure
instance GHC.Base.Applicative Control.Effects.Pure
instance GHC.Base.Monad Control.Effects.Pure
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Effects.Base m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Effects.Base m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Effects.Base m)
instance (GHC.Base.Applicative m, GHC.Base.Applicative n, GHC.Base.Monad m, GHC.Base.Monad n, Control.Effects.AutoLiftInternal (Control.Effects.Layer e m) (Control.Effects.Base n) (Control.Effects.Layer e m) (Control.Effects.Base n)) => Control.Effects.AutoLift e m (Control.Effects.Base n)
instance (GHC.Base.Applicative m, GHC.Base.Monad m, Control.Effects.AutoLiftInternal (Control.Effects.Layer e m) (Control.Effects.Layer d n) (Control.Effects.Layer e m) (Control.Effects.Layer d n)) => Control.Effects.AutoLift e m (Control.Effects.Layer d n)
instance (GHC.Base.Applicative m, GHC.Base.Applicative n, GHC.Base.Monad m, GHC.Base.Monad n, Control.Effects.AutoLiftInternal (Control.Effects.Base m) (Control.Effects.Base n) (Control.Effects.Base m) (Control.Effects.Base n)) => Control.Effects.AutoLiftBase m (Control.Effects.Base n)
instance (GHC.Base.Applicative m, GHC.Base.Monad m, Control.Effects.AutoLiftInternal (Control.Effects.Base m) (Control.Effects.Layer e n) (Control.Effects.Base m) (Control.Effects.Layer e n)) => Control.Effects.AutoLiftBase m (Control.Effects.Layer e n)
instance (GHC.Base.Applicative m, GHC.Base.Monad m) => Control.Effects.AutoLiftInternal m m (Control.Effects.Base n) (Control.Effects.Base n)
instance Control.Effects.AutoLiftInternal m1 m2 (Control.Effects.Base n1) n2 => Control.Effects.AutoLiftInternal m1 (Control.Effects.Layer r m2) (Control.Effects.Base n1) (Control.Effects.Layer s n2)
instance Control.Effects.AutoLiftInternal m1 m2 n1 n2 => Control.Effects.AutoLiftInternal m1 m2 (Control.Effects.Layer r n1) (Control.Effects.Layer s n2)
module Control.Effects.Cont
shift :: AutoLift r m n => Effect r m -> ((m a -> m r) -> m r) -> n a
reset :: Monad m => Handler a a m a
module Control.Effects.Either
throwEither :: AutoLift (Either e r) m n => Effect (Either e r) m -> e -> n Void
catchEither :: Monad m => (e -> m a) -> Handler (Either e a) a m a
module Control.Effects.Error
throwError :: AutoLift ((e -> m r) -> m r) m n => Effect ((e -> m r) -> m r) m -> e -> n Void
catchError :: Monad m => (e -> m a) -> Handler ((e -> m a) -> m a) a m a
module Control.Effects.NonDet
choose :: (AutoLift r m n, Monoid r, Foldable f) => Effect r m -> f a -> n a
guard :: (Monoid r, AutoLift r m n) => Effect r m -> Bool -> n ()
dfs :: Monad m => (a -> r) -> Handler r r m a
set :: Monad m => Handler (Set a) (Set a) m a
alternatives :: (Monad m, Alternative f) => Handler (WrappedAlt f a) (f a) m a
accumulate :: (Monad m, Newtype n) => (a -> n) -> Handler n (O n) m a
bfs :: (Monad m, Monoid r) => (a -> r) -> Handler (BFS r) r m a
instance (GHC.Base.Applicative m, GHC.Base.Monoid r) => GHC.Base.Monoid (Control.Applicative.WrappedMonad m r)
instance Control.Newtype.Newtype (Control.Effects.NonDet.WrappedAlt m a)
instance GHC.Base.Alternative f => GHC.Base.Monoid (Control.Effects.NonDet.WrappedAlt f a)
instance GHC.Base.Monoid r => GHC.Base.Monoid (Control.Effects.NonDet.BFS r)
instance GHC.Base.Monoid r => Control.Newtype.Newtype (Control.Effects.NonDet.BFS r)
module Control.Effects.State
type State s m a = s -> m a
get :: AutoLift (State s m a) m n => Effect (State s m a) m -> n s
put :: AutoLift (State s m a) m n => Effect (State s m a) m -> s -> n ()
(=:) :: AutoLift (State s m a) m n => Effect (State s m a) m -> n s -> n ()
infixr 3 =:
modify :: AutoLift (State s m a) m n => Effect (State s m a) m -> (s -> s) -> n ()
local :: AutoLift (State s m a) m n => Effect (State s m a) m -> (s -> s) -> n b -> n b
ref :: Monad m => s -> Handler (State s m a) a m a
module Control.Effects.Writer
tell :: (AutoLift (w, r) m n, Monoid w) => Effect (w, r) m -> w -> n ()
writer :: (Monad m, Monoid w) => Handler (w, a) (w, a) m a