The effect-handlers package

[Tags:benchmark, library, mit, test]

This is an extensible effects library for Haskell taking inspiration from the Eff language http://www.eff-lang.org/.

See these papers for the ideas and theory behind the library:

Implementation wise it's most close to extensible-effects http://hackage.haskell.org/package/extensible-effects (also see the Extensible Effects paper) but it implements deep handlers instead of shallow.

import Control.Effects.Cont.Eff
import Control.Effects.Cont.Reader
import Control.Effects.Cont.Exception

program = do
  v <- ask
  if v < 15
  then throw $ show v
  else return (v+1)

run n = runPure . handle exceptionHandler . handle (readerHandler n)

res :: Integer -> Either String Integer
res n = run n program

[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.0.6, 0.1.0.7, 0.1.0.8
Dependencies base (>=4.7 && <5), free (>=4.9 && <5), kan-extensions (>=4.1 && <6), mtl (>=2.1 && <3) [details]
License MIT
Author Andraz Bajt, Blaz Repas
Maintainer Andraz Bajt <andraz@bajt.me>
Category Control
Home page https://github.com/edofic/effect-handlers
Bug tracker https://github.com/edofic/effect-handlers/issues
Uploaded Thu Apr 28 15:06:03 UTC 2016 by edofic
Distributions LTSHaskell:0.1.0.8, NixOS:0.1.0.8, Stackage:0.1.0.8, Tumbleweed:0.1.0.8
Downloads 1200 total (34 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2016-11-26 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for effect-handlers

Readme for effect-handlers-0.1.0.8

effect-handlers

This is an extensible effects library for Haskell taking inspiration from the Eff language.

See these papers for the ideas and theory behind the library:

Implementation wise it's most close to extensible-effects (also see the Extensible Effects paper) but it implements deep handlers instead of shallow.

What does this library provide?

There is the Eff monad type and modules for pre-implemented effects.

  • Exception
  • IO
  • Reader
  • Search
  • State
  • Writer

It is easy to define your own effects and combine them.

Example

Most of the types are inferred, you only need to provide enough to tell the compiler how to specialize some effect handlers (e.g. readerHandler).

import Control.Effects.Cont.Eff
import Control.Effects.Cont.Reader
import Control.Effects.Cont.Exception

program = do
  v <- ask
  if v < 15 
  then throw $ show v
  else return (v+1)

run n = runPure 
                 . handle exceptionHandler 
                 . handle (readerHandler n)

res :: Integer -> Either String Integer
res n = run n program

Documentation

Haddock docs are available online