effin

A Typeable-free implementation of extensible effects

https://github.com/YellPika/effin

Version on this page:0.3.0.2
LTS Haskell 9.21:0.3.0.3
Stackage Nightly 2017-07-25:0.3.0.2
Latest on Hackage:0.3.0.3

See all snapshots effin appears in

BSD-3-Clause licensed by Anthony Vandikas
Maintained by [email protected]
This version can be pinned in stack with:effin-0.3.0.2@sha256:5fe62dcc967c0adf12ec1813338f1d3f13fbe4e98b8201e0fabecec1426e3ea1,2562
Depends on 2 packages(full list with versions):

This package implements extensible effects, an alternative to monad transformers. The original paper can be found at http://okmij.org/ftp/Haskell/extensible/exteff.pdf. The main differences between this library and the one described in the paper are that this library does not use the Typeable type class, does not require that effects implement the Functor type class, and has a simpler API for handling effects.

For example, the following code implements a handler for exceptions:

newtype Exception e = Throw e

runException :: Effect (Exception e :+ es) a -> Effect es (Either e a)
runException = eliminate
    (\x -> return (Right x))
    (\(Throw e) k -> return (Left e))

Compare this to the corresponding code in extensible-effects (http://hackage.haskell.org/package/extensible-effects):

runExc :: Typeable e => Eff (Exc e :> r) a -> Eff r (Either e a)
runExc = loop . admin
  where
    loop (Val x) = return (Right x)
    loop (E u)   = handleRelay u loop (\(Exc e) -> return (Left e))

In particular, effect implementors are not required to do any recursion, thereby making effect handlers more composeable.