Copyright | (c) 2020 Microsoft Research; Daan Leijen; Ningning Xie |
---|---|
License | MIT |
Maintainer | xnning@hku.hk; daan@microsoft.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Some definitions for common effects.
Synopsis
- data Reader a e ans = Reader {}
- reader :: a -> Eff (Reader a :* e) ans -> Eff e ans
- data State a e ans = State {}
- state :: a -> Eff (State a :* e) ans -> Eff e ans
- data Writer a e ans = Writer {}
- writer :: Monoid a => Eff (Writer a :* e) ans -> Eff e (ans, a)
- data Except a e ans = Except {
- throwError :: !(forall b. Op a b e ans)
- catchError :: Eff (Except a :* e) ans -> (a -> Eff e ans) -> Eff e ans
- exceptEither :: Eff (Except a :* e) ans -> Eff e (Either a ans)
- exceptMaybe :: Eff (Except a :* e) ans -> Eff e (Maybe ans)
- exceptDefault :: ans -> Eff (Except a :* e) ans -> Eff e ans
- data Choose e ans = Choose {}
- chooseFirst :: Eff (Choose :* e) ans -> Eff e (Maybe ans)
- chooseAll :: Eff (Choose :* e) a -> Eff e [a]
Reader
A standard reader effect for values of type a
.
reader :: a -> Eff (Reader a :* e) ans -> Eff e ans Source #
A handler for a Reader
effect with a value of type a
.
State
A standard state effect of type a
.
state :: a -> Eff (State a :* e) ans -> Eff e ans Source #
A state handler that takes an initial state of type a
.
Writer
A standard writer effect of type a
writer :: Monoid a => Eff (Writer a :* e) ans -> Eff e (ans, a) Source #
A standard Writer
handler for any monoidal type a
. Returns the final
result of type ans
and the appended tell
arguments.
Exception
A standard exception effect, throwing values of type a
.
Except | |
|
exceptEither :: Eff (Except a :* e) ans -> Eff e (Either a ans) Source #
Transform an exception effect to an Either
type.
exceptMaybe :: Eff (Except a :* e) ans -> Eff e (Maybe ans) Source #
Transform an exception effect to a Maybe
type.
exceptDefault :: ans -> Eff (Except a :* e) ans -> Eff e ans Source #
Remove the exception effect using a default value in case an exception was thrown.
Choice
Choose implements backtracking.
chooseFirst :: Eff (Choose :* e) ans -> Eff e (Maybe ans) Source #
Return the first result found in a computation using choose
for backtracking.
chooseAll :: Eff (Choose :* e) a -> Eff e [a] Source #
Return all possible results found in a computation using choose
for backtracking