package yuujinchou

  1. Overview
  2. Docs

Module Yuujinchou.ActionSource

The Action module implements the engine running the patterns.

Types

Sourcetype 'a compiled_pattern

The abstract type of compiled patterns.

Sourcetype '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.

Sourcetype '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.

Compilers

Sourceval compile : join:('a -> 'a -> 'a) -> meet:('a -> 'a -> 'a) -> 'a Pattern.pattern -> ('a compiled_pattern, 'a error) 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.

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

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

Matching

Sourceval 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.

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

Pretty Printers

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

Pretty printer for error.

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

Pretty printer for matching_result.