Skip to content
/ MpEff Public

Efficient effect handlers based on Evidence Passing Semantics.

License

Notifications You must be signed in to change notification settings

xnning/MpEff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Efficient effect handlers based on Evidence Passing Semantics.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published