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))
match_ t
pulls out the underlying function of t