Description
Efficient effect handlers based on evidence translation.
Description
See the Control.Ev.Eff
module or README.md for further information
README.md
EvEff: Efficient effect handlers based on Evidence translation
Efficient effect handlers based on evidence translation [1]. The interface and design is described in detail in "Effect Handlers in Haskell, Evidently", Ningning Xie and Daan Leijen, Haskell 2020.
An example of defining and using a Reader
effect:
{-# LANGUAGE TypeOperators, FlexibleContexts, Rank2Types #-}
import Control.Ev.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 s
Enjoy,
Daan Leijen and Ningning Xie, May 2020.
[1] "Effect Handlers, Evidently", Ningning Xie et al., ICFP 2020 (pdf).