mpeff: Efficient effect handlers based on evidence-passing semantics

[ control, effect, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

See the Control.Mp.Eff module or README.md for further information


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), ghc-prim, primitive [details]
License MIT
Copyright (c) 2020, Microsoft Research, Ningning Xie, Daan Leijen
Author Ningning Xie, Daan Leijen
Maintainer xnning@hku.hk;daan@microsoft.com
Category Control, Effect
Home page https://github.com/xnning/mpeff#readme
Bug tracker https://github.com/xnning/mpeff/issues
Source repo head: git clone https://github.com/xnning/mpeff
Uploaded by ningningxie at 2021-08-09T18:59:17Z
Distributions NixOS:0.1.0.0
Downloads 232 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-08-09 [all 1 reports]

Readme for mpeff-0.1.0.0

[back to package description]

MpEff: Efficient effect handlers based on Evidence Passing Semantics

Efficient effect handlers based on Evidence Passing Semantics. The implementation is based on

Generalized Evidence Passing for Effect Handlers, Ningning Xie and Daan Leijen, 2021 (pdf).

The implementation is closely based on the Ev.Eff library described in detail in

Effect Handlers in Haskell, Evidently, Ningning Xie and Daan Leijen, Haskell 2020 (pdf).

The Mp.Eff and Ev.Eff libraries expose the exact same interface, but the Mp.Eff library can express full effect handler semantics, including non-scoped resumptions -- it is slightly slower though (see the 2021 paper for benchmarks and a detailed comparison).

Installation:

  • First install stack
  • Build with > stack build

An example of defining and using a Reader effect:

{-# LANGUAGE  TypeOperators, FlexibleContexts, Rank2Types #-}
import Control.Mp.Eff

-- A @Reader@ effect definition with one operation @ask@ of type @()@ to @a@.
data Reader a e ans = Reader{ ask :: Op () a e ans }

greet :: (Reader String :? e) => Eff e String
greet = do s <- perform ask ()
           return ("hello " ++ s)

test :: String
test = runEff $
       handler (Reader{ ask = value "world" }) $  -- @:: Reader String () Int@
       do s <- greet                              -- executes in context @:: Eff (Reader String :* ()) Int@
          return (length s)

Enjoy,

Ningning Xie and Daan Leijen, Mar 2021.