mpeff: Efficient effect handlers based on evidence-passing semantics

[ control, effect, library, mit ] [ Propose Tags ]

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

[Skip to Readme]


Maintainer's Corner

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Change log
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
Category Control, Effect
Home page
Bug tracker
Source repo head: git clone
Uploaded by ningningxie at 2021-08-09T18:59:17Z
Distributions NixOS:
Downloads 73 total (1 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-

[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).


  • 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)


Ningning Xie and Daan Leijen, Mar 2021.