ppx_viewpattern

ci workflow status GitHub release status opam package status

Transformation for view patterns in OCaml. Attempts to imitate Haskell view patterns.

Installation

opam install ppx_viewpattern

Usage

In dune:

(preprocess (pps ppx_viewpattern))

Syntax

Use [%view? pat when exp] as a pattern to apply exp to whatever the pattern is matching and match the result of the exp application against pat. Analogous to the Haskell view pattern exp -> pat.

See example/ for example usage.

Supported in:

Caveats

A view pattern disables redundant-case and partial-match warnings for the corresponding match/function.

Currently unsupported in: