JonasHoefer / scoped-effects-agda

An implementation of scoped algebraic effects and handlers in Agda.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scoped Effects in Agda

This repository contains an implementation of scoped algebraic effects and handlers in Agda. The implementation is based on work by Piróg et al. and Fu and Selinger.

The library was developed as part of a bachelor's thesis which can be found in the thesis directory.

Structure

The implementation in src utilizes scoped algebras, as described by Wu et al., that are implemented using a version of higher order folds, as described by Fu and Selinger.

The old directory contains an implementation using explicit scope delimiters and some ultimately failed attempts using higher order functors. These two implementations closely follow "Effect Handlers in Scope". They are kept for historical and documentation purposes.

Example

The library implements so called scoped algebraic effects. These effects can implement operations which create local scopes, for example catch and local. Furthermore, the library contains an implementation of a sharing effect for nondeterminism. The implementation is based on work by Bunkenburg. This effect allows simulating Curry's call-time choice semantics.

coin : ⦃ Nondet ∈ effs ⦄  Prog effs ℕ
coin = pure 0 ⁇ pure 1

doubleSharedCoin : ⦃ Nondet ∈ effs ⦄  ⦃ State SID ∈ effs ⦄  ⦃ Share ∈ effs ⦄  Prog effs ℕ
doubleSharedCoin = do
  c  share coin
  ⦇ c + c ⦈
  
_ : runCTC doubleSharedCoin ≡ 02 ∷ []
_ = refl

Versions

Bibliography

About

An implementation of scoped algebraic effects and handlers in Agda.


Languages

Language:TeX 64.8%Language:Agda 32.3%Language:Haskell 2.7%Language:Shell 0.2%