package yuujinchou

  1. Overview
  2. Docs

The Language module defines the language of modifiers.


type 'hook t

The abstract type of modifiers, parametrized by the type of hook labels. See hook for hook labels.

Construct terms using builders in Language and execute them using Modifier.S.modify.

val equal : ('hook -> 'hook -> bool) -> 'hook t -> 'hook t -> bool

Checking equality.

Modifier Builders


val any : 'hook t

any keeps the content of the current tree. It is an error if the tree is empty (no name to match). To avoid the emptiness checking, use the identity modifier seq []. This is equivalent to only [].

val only : Trie.path -> 'hook t

only path keeps the subtree rooted at path. It is an error if the subtree was empty.

val in_ : Trie.path -> 'hook t -> 'hook t

in_ path m runs the modifier m on the subtree rooted at path. Bindings outside the subtree are kept intact. For example, in_ ["x"] any will keep y (if existing), while only ["x"] will drop y.


val none : 'hook t

none drops everything. It is an error if the tree was already empty (nothing to drop). To avid the emptiness checking, use the empty modifier union [].

val except : Trie.path -> 'hook t

except p drops the subtree rooted at p. It is an error if there was nothing in the subtree. This is equivalent to in_ p none.


val renaming : Trie.path -> Trie.path -> 'hook t

renaming path path' relocates the subtree rooted at path to path'. The existing bindings at path' (if any) will be dropped. It is an error if the subtree was empty (nothing to move).


val seq : 'hook t list -> 'hook t

seq [m0; m1; m2; ...; mn] runs the modifiers m0, m1, m2, ..., mn in order. In particular, seq [] is the identity modifier.


val union : 'hook t list -> 'hook t

union [m0; m1; m2; ...; mn] calculates the union of the results of individual modifiers m0, m1, m2, ..., mn. In particular, union [] is the empty modifier. The Modifier.handler.shadow effect will be performed to resolve name conflicts, with an intention for results of a modifier to shadow those of previous ones.

Custom Hooks

val hook : 'hook -> 'hook t

hook h applies the hook labelled h to the entire trie by performing the Modifier.handler.hook effect.

Ugly Printing

val dump : (Stdlib.Format.formatter -> 'hook -> unit) -> Stdlib.Format.formatter -> 'hook t -> unit

dump dump_hook m dumps the internal representation of m for debugging, where dump_hook is the ugly printer for hook labels (see hook).


Innovation. Community. Security.