package ppx_viewpattern

All checked builds pass
  1. Overview
  2. Docs
View patterns in OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ppx_viewpattern-0.1.1.tbz
sha256=7edc8a6c112fd430efa62d77c3eb8c1e1320fa5fff9e86e67cced0918b5371bf
sha512=3f41006389d724198a94bdf1282d38509a6d0a7bef9c28d501f96904f35cd6f8835c2e3b1b2269dd573a18b5fc3489731d2250717daa304e9640170e0af858ca

Description

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

Added to opam-repository:

README

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:

  • match ... with ... cases,
  • function ... cases,
  • fun ... -> ... arguments,
  • let ... in ... expression binding left-hand sides,
  • try ... with ... cases,
  • nested inside the pat and exp parts of a view pattern itself.

Caveats

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

Currently unsupported in:

  • let ... definition left-hand sides (at top level or in modules).

Dependencies (2)

  1. ppxlib >= "0.36.0"
  2. dune >= "2.8"

Dev Dependencies (3)

  1. odoc with-doc
  2. qcheck-ounit with-test
  3. ounit2 with-test

Optional Dependencies

None

Used by

None

Conflicts

None

Build status

Results of building ppx_viewpattern with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.1.1 (this version) good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure