package yuujinchou

  1. Overview
  2. Docs

The signature of the engine.

include Param
type data

The type of data held by the bindings. The difference between data and tags is that the data will survive the efficient retagging. See Trie.retag.

type tag

The type of tags attached to the bindings. The difference between data and tags is that tags can be efficiently reset. See Trie.retag.

type hook

The type of modifier hook labels. This is for extending the modifier language.

type context

The type of contexts passed to each call of Modifier.S.modify for the effect handler to distinguish different function calls.

val modify : ?context:context -> ?prefix:Trie.bwd_path -> hook Language.t -> (data, tag) Trie.t -> (data, tag) Trie.t

modify modifier trie runs the modifier on the trie and return the transformed trie.

  • parameter context

    The context sent to the effect handlers. If unspecified, effects come with None as their context.

  • parameter prefix

    The prefix prepended to any path or prefix sent to the effect handlers. The default is the empty path (Emp).

val run : (unit -> 'a) -> (data, tag, hook, context) handler -> 'a

run f h initializes the engine and runs the thunk f, using h to handle modifier effects. See handler.

val try_with : (unit -> 'a) -> (data, tag, hook, context) handler -> 'a

try_with f h runs the thunk f, using h to handle the intercepted modifier effects. See handler.

Currently, try_with is an alias of run, but try_with is intended to use within run to intercept effects, while run is intended to be at the outermost layer to handle effects. That is, the following is the expected program structure:

run @@ fun () ->
(* code *)
try_with f { ... }
(* more code *)
val perform : (data, tag, hook, context) handler

A handler that reperforms the effects. It can also be used to manually trigger the effects; for example, perform.not_found (Emp #< "a" #< "b") will perform the not_found effect to be handled by the outer handler.

OCaml

Innovation. Community. Security.