package ppx_optional

Build not checked
  1. Overview
  2. Docs
Pattern matching on flat options

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ppx_optional-v0.13.0.tar.gz
sha256=78b9f802f1a4043d8e9b1c4b7b94186f216723b798243a0cb451c9bc4e1cacab
md5=e9b763741e21f66579fb3ac0230ee772

Description

A ppx rewriter that rewrites simple match statements with an if then else expression.

Added to opam-repository:

README

ppx_optional - match statements for zero-alloc options

A ppx rewriter that rewrites simple match statements with an if then else expression.

Syntax

ppx_optional rewrites the extension match%optional in expressions. It requires that a module Optional_syntax is in scope, and that it has is_none and unsafe_value values.

For instance:

match%optional e with
| None -> none_expression
| Some x -> some_expression

becomes:

if Optional_syntax.is_none e then begin
   none_expression
end else begin
   let x = Optional_syntax.unsafe_value e in
   some_expression
end

Usage

This is normally used to safely access an optional value while avoiding allocation for immediate values (e.g. Immediate.{Char,Bool,Int}.Option, Fixed.Option, Price.Fixed.Option, etc...).

Dependencies (4)

  1. ppxlib >= "0.9.0"
  2. dune >= "1.5.1"
  3. base >= "v0.13" & < "v0.14"
  4. ocaml >= "4.04.2"

Dev Dependencies

None

Used by (3)

  1. float_option
  2. ooh
  3. ppx_jane < "v0.14.0"

Conflicts

None

Build status

Results of building ppx_optional with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. 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.

This version is not in the latest run; the versions below are.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
v0.17.0 n/a n/a good good good
v0.16.0 n/a good good good good
v0.15.0 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