std/core/hnd▲toc

Internal effect handler primitives.

Internal primitives to implement evidence based algebraic effect handlers. These are emitted by the compiler during evidence translation and this module is always implicitly imported.

The paper:

Ningning Xie, and Daan Leijen. Generalized Evidence Passing for Effect Handlers, or efficient compilation of effect handlers to C. Proceedings of the ACM International Conference on Functional Programming (ICFP'21), August 2021, Vol 5: pp. 71, doi: 10.1145/3473576. https://​www.​microsoft.​com/​en-​us/​research/​publication/​generalized-​evidence-​passing-​for-​effect-​handlers-​or-​efficient-​compilation-​of-​effect-​handlers-​to-​c/​

describes how the monadic evidence translation works on which this module is based. This module is compiled without monadic translation and thus we need to do this by hand in this module which allows us to implement most primitives directly in Koka keeping the external C/JavaScript/etc primitives to a minimum.

alias cfcstd/core/hnd/cfc: V = int32std/core/types/int32: V

control flow context: -1: none: bottom /
0: except: never resumes 1: linear: resumes exactly once   / 2: affine: resumes never or once | 3: multi: resumes never, once, or multiple times.

type clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<a,b,e,c>
type clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<a,b,c,e,d>
fun clause-control1( clause : (x : a, k : (b) -> e d) -> e d ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<a,b,c,e,d>
fun clause-control3( op : (x1 : a, x2 : b, x3 : c, k : (d) -> e b1) -> e b1 ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(a, b, c),d,a1,e,b1>
fun clause-control4( op : (x1 : a, x2 : b, x3 : c, x4 : d, k : (a1) -> e c1) -> e c1 ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(a, b, c, d),a1,b1,e,c1>
fun clause-never3( op : (a, b, c) -> e b1 ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(a, b, c),d,a1,e,b1>
fun clause-never4( op : (a, b, c, d) -> e c1 ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(a, b, c, d),a1,b1,e,c1>
fun clause-tail-noyield3( op : (a, b, c) -> e d ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(a, b, c),d,a1,e,b1>
fun clause-tail-noyield4( op : (a, b, c, d) -> e a1 ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(a, b, c, d),a1,b1,e,c1>
fun clause-tail3( op : (a, b, c) -> e d ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(a, b, c),d,a1,e,b1>
fun clause-tail4( op : (a, b, c, d) -> e a1 ) : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(a, b, c, d),a1,b1,e,c1>
type clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<a,b,c,d,e,a1>
fun clause-control2( clause : (x1 : a, x2 : b, k : (c) -> e a1) -> e a1 ) : clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<a,b,c,d,e,a1>
type evstd/core/hnd/ev: ((E, V) -> V) -> V<a>

Effect handler evidence of a handler h in the context.

alias ev-indexstd/core/hnd/ev-index: V = ssize_tstd/core/types/ssize_t: V
type htagstd/core/hnd/htag: ((E, V) -> V) -> V<a>

The tag of a handler identifies the type at runtime (e.g. "exn/core/std").

type resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<a,e,e1,b>
type yield-infostd/core/hnd/yield-info: V
fun finally( fin : () -> e types/(), action : () -> e a ) : e a
fun initially( init : (intstd/core/types/int: V) -> e types/(), action : () -> e a ) : e a
fun local-var( init : a, action : (l : local-varstd/core/types/local-var: (H, V) -> V<h,a>) -> <localstd/core/types/local: H -> X<h>|e> b ) : <localstd/core/types/local: H -> X<h>|e> b
fun unsafe-try-finalize( action : () -> e a ) : e eitherstd/core/types/either: (V, V) -> V<yield-infostd/core/hnd/yield-info: V,a>
fun yield-bind( x : a, next : (a) -> e b ) : e b
fun yield-bind2( x : a, extend : (a) -> e b, next : (a) -> e b ) : e b
fun yield-extend( next : (a) -> e b ) : e b
fun yielding(): boolstd/core/types/bool: V
fun yielding-non-final(): boolstd/core/types/bool: V
private import std/core/typesstd/core/types