Skip to content

An implementation of scoped algebraic effects and handlers in Agda.

Notifications You must be signed in to change notification settings

JonasHoefer/scoped-effects-agda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published