Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Control.Eff
Contents
Description
A monadic library for implementing effectful computation in a modular way.
This module provides the Eff
monad - the base type for all effectful
computation.
The Member
typeclass is the main interface for describing which effects
are necessary for a given function.
Consult the Control.Eff.QuickStart
module and the readme for gentle
introductions.
To use extensible effects effectively some language extensions are necessary/recommended.
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MonoLocalBinds #-}
Effect type
run :: Eff '[] w -> w Source #
Get the result from a pure computation
A pure computation has type Eff '[] a
. The empty effect-list indicates that
no further effects need to be handled.
The monad that all effects in this library are based on.
An effectful computation is a value of type `Eff r a`.
In this signature, r
is a type-level list of effects that are being
requested and need to be handled inside an effectful computation.
a
is the computation's result similar to other monads.
A computation's result can be retrieved via the run
function.
However, all effects used in the computation need to be handled by the use
of the effects' run*
functions before unwrapping the final result.
For additional details, see the documentation of the effects you are using.
Instances
Effect list
class FindElem t r => Member (t :: * -> *) r Source #
Typeclass that asserts that effect t
is contained inside the effect-list
r
.
The FindElem
typeclass is an implementation detail and not required for
using the effect list or implementing custom effects.
Instances
FindElem t r => Member t r Source # | |
t ~ s => Member t (s ': ([] :: [* -> *])) Source # | Explicit type-level equality condition is a dirty
hack to eliminate the type annotation in the trivial case,
such as There is no ambiguity when finding instances for
The only case we have to concerned about is |
class Member t r => SetMember (tag :: k -> * -> *) (t :: * -> *) r | tag r -> t Source #
This class is used for emulating monad transformers
type family (ms :: [* -> *]) <:: r where ... Source #
A useful operator for reducing boilerplate in signatures.
The following lines are equivalent.
(Member (Exc e) r, Member (State s) r) => ... [ Exc e, State s ] r = ...
Equations
'[] <:: r = (() :: Constraint) | |
(m ': ms) <:: r = (Member m r, (<::) ms r) |