package yuujinchou

  1. Overview
  2. Docs
Module type
Class type

The Action module implements the engine running the patterns.


type 'a compiled_pattern

The abstract type of compiled patterns.

type 'a matching_result = [
  1. | `NoMatch

    The pattern does not match the name.

  2. | `Matched of (Pattern.path * 'a) list

    The pattern matches the name and outputs a list of tagged new names.


The result type of pattern matching. See outcomes.

type 'a error =
  1. | ReplacementNotUsed of 'a Pattern.pattern

    Renaming patterns are run under the inverse mode.

  2. | EmptyMeet of 'a Pattern.pattern

    The join patterns under the inverse mode (or, equivalently, the meet patterns under the normal mode) have no subpatterns.


The type of errors due to the violation of some invariant of patterns. See invariants. It should be impossible to violate these invariants unless Pattern.unsafe_meet or Pattern.unsafe_inv is used.

The pattern embedded in the error message is the fragment that violates the invariant. The pattern pat in EmptyMeet pat is not useful on its own---it must be PatJoin []---but it facilitates using or-patterns in error handling.


val compile : join:('a -> 'a -> 'a) -> meet:('a -> 'a -> 'a) -> 'a Pattern.pattern -> ('a compiled_pattern, 'a error) Stdlib.result

The pattern compiler.

  • parameter join

    The join operator to resolve conflicting attributes. See attributes.

  • parameter meet

    The meet operator to resolve conflicting attributes. See attributes.

val compile_ : unit Pattern.pattern -> (unit compiled_pattern, unit error) Stdlib.result

This is compile specialized to unit pattern where the attribute type is unit.


val run : 'a compiled_pattern -> default:'a -> Pattern.path -> 'a matching_result

run pat ~default path runs a compiled pattern to match path with the default attribute being default.

  • parameter default

    The default attribute for the engine to start with. See attributes.

val run_ : unit compiled_pattern -> Pattern.path -> unit matching_result

This is run specialized to unit pattern where the attribute type is unit.

Pretty Printers

val pp_error : (Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> 'a error -> unit

Pretty printer for error.

val pp_matching_result : (Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> 'a matching_result -> unit

Pretty printer for matching_result.


Innovation. Community. Security.