ppx_optional

Pattern matching on flat options
README

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...).

Install
Published
31 May 2020
Sources
ppx_optional-v0.14.0.tar.gz
md5=0c85a3233f660a500f7d7481a1ab3c6c
Dependencies
ppxlib
>= "0.11.0"
dune
>= "2.0.0"
base
>= "v0.14" & < "v0.15"
ocaml
>= "4.04.2"
Reverse Dependencies
ppx_jane
= "v0.14.0"