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.
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.
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 ≡ 0 ∷ 2 ∷ []
_ = refl
- Agda, versions 2.6.1
- Agda Standard Library, version 1.4