package accessor

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

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

variant ~match_:Either.first ~construct:Fn.id = Fn.id
Fn.compose
  (variant ~match_:m1 ~construct:c1)
  (variant ~match_:m2 ~construct:c2)
=
variant
  ~match_:(fun a ->
    match m1 a with
    | Second _ as a -> a
    | First a ->
      match m2 a with
      | First _ as a -> a
      | Second a -> Second (c1 a))
  ~construct:(Fn.compose c1 c2)