-- 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.2
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 AutoLiftInternal m1 m2 n1 n2 => AutoLiftInternal m1 m2 (Layer r n1) (Layer s n2)
instance AutoLiftInternal m1 m2 (Base n1) n2 => AutoLiftInternal m1 (Layer r m2) (Base n1) (Layer s n2)
instance (Applicative m, Monad m) => AutoLiftInternal m m (Base n) (Base n)
instance (Applicative m, Applicative n, Monad m, Monad n, AutoLiftInternal (Base m) (Layer e n) (Base m) (Layer e n)) => AutoLiftBase m (Layer e n)
instance (Applicative m, Applicative n, Monad m, Monad n, AutoLiftInternal (Base m) (Base n) (Base m) (Base n)) => AutoLiftBase m (Base n)
instance (Applicative m, Applicative n, Monad m, Monad n, AutoLiftInternal (Layer e m) (Layer d n) (Layer e m) (Layer d n)) => AutoLift e m (Layer d n)
instance (Applicative m, Applicative n, Monad m, Monad n, AutoLiftInternal (Layer e m) (Base n) (Layer e m) (Base n)) => AutoLift e m (Base n)
instance Monad m => Monad (Base m)
instance Applicative m => Applicative (Base m)
instance Functor m => Functor (Base m)
instance Monad Pure
instance Applicative Pure
instance Functor Pure
instance (Monoid e, Applicative m) => MonadPlus (Layer e m)
instance Monad (Layer e m)
instance (Monoid e, Applicative m) => Alternative (Layer e m)
instance Applicative (Layer e m)
instance Functor (Layer e m)
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, Monoid r) => (a -> r) -> Handler r r m a
set :: (Monad m, Ord a) => 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 o) => (a -> n) -> Handler n o m a
bfs :: (Monad m, Monoid r) => (a -> r) -> Handler (BFS r) r m a
instance Monoid r => Newtype (BFS r) r
instance Monoid r => Monoid (BFS r)
instance Alternative f => Monoid (WrappedAlt f a)
instance Newtype (WrappedAlt m a) (m a)
instance (Applicative m, Monoid r) => Monoid (WrappedMonad m 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 ()
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