Up

Module Documented_match_statement = Documented_match_statement

Signature

type ('input, 'output) case = {
pattern
: 'input list ;
documentation
: string ;
value
: 'output ;
}
type ('input, 'output) t = {
specific_cases
: ('input, unit -> 'output) case list ;
catchall_case
: [
| `Used of ([
| `Catchall
], 'input -> 'output) case
| `Unused of unit -> 'output
]
;
}
val map : ('input, 'output1) t -> f:('output1 -> 'output2) -> ('input, 'output2) t
val map_case : ('input, unit -> 'output1) case -> f:('output1 -> 'output2) -> ('input, unit -> 'output2) case
val map_cases : ('input, unit -> 'output1) case list -> f:('output1 -> 'output2) -> ('input, unit -> 'output2) case list
val map_pattern : ('input1, 'output) t -> f1:('input1 -> 'input2) -> f2:('input2 -> 'input1) -> ('input2, 'output) t
val prepend : specific_cases:('input, unit -> 'output) case list -> ('input, 'output) t -> ('input, 'output) t

prepend ~specific_cases t matches on specific_cases before moving on to t.

A common situation is representing let f t x = match x with | `A -> ... | `B -> ... | _ -> TODO: CUSTOM

which can be done by combining prepend and map: let f' = prepend ~specific_cases:{pattern = `A;...};{pattern = `B;...} (map g' ~f:(fun h t -> TODO: CUSTOM))

val match_ : ('input, 'output) t -> 'input -> 'output

match_ t pulls out the underlying function of t

val documentation : ('input, 'output) t -> input_to_string:('input -> string) -> title:string -> string list