Module Core_kernel.Optional_syntax

Interfaces for use with match%optional. Idiomatic usage is to have a module M like:

        module M : sig
          type t

          module Optional_syntax : Optional_syntax.S
            with type t := t
            with type value := ...
        end = struct
          ...

          module Optional_syntax = struct
            module Optional_syntax = struct
              let is_none = is_node
              let unchecked_value = unchecked_value
            end
          end
        end

Then, uses look like:

        let open M.Optional_syntax in
        match%optional m with
        | None   -> ?
        | Some v -> ?

The reason for the double module Optional_syntax is so that open M.Optional_syntax puts in scope only module Optional_syntax; match%optional then expands to references to Optional_syntax.is_none and Optional_syntax.unchecked_value.

For more details on the syntax extension, see ppx/ppx_optional/README.md.