Library
Module
Module type
Parameter
Class
Class type
The Action
module implements the engine running the patterns.
type 'a matching_result = [
| `NoMatch
The pattern does not match the name.
*)| `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 =
| ReplacementNotUsed of 'a Pattern.pattern
Renaming patterns are run under the inverse mode.
*)| 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) result
The pattern compiler.
val compile_ :
unit Pattern.pattern ->
(unit compiled_pattern, unit error) 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
.
val run_ : unit compiled_pattern -> Pattern.path -> unit matching_result
This is run
specialized to unit pattern
where the attribute type is unit
.
val pp_error :
(Format.formatter -> 'a -> unit) ->
Format.formatter ->
'a error ->
unit
Pretty printer for error
.
val pp_matching_result :
(Format.formatter -> 'a -> unit) ->
Format.formatter ->
'a matching_result ->
unit
Pretty printer for matching_result
.