package accessor

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type ('a, 'b) t
val optional : ('at -> ('a * ('b -> 'bt), 'bt) Base.Either.t) -> ('a, 'b) t -> ('at, 'bt) t

A legal implementation of this function must satisfy the following properties:

optional (fun a -> First (a, Fn.id)) = Fn.id
Fn.compose (optional f) (optional g)
=
optional (fun a ->
  match f a with
  | Second _ as a -> a
  | First (a, j) ->
    match g a with
    | First (a, k) -> First (a, Fn.compose j k)
    | Second a -> Second (j a))
OCaml

Innovation. Community. Security.