package n_ary

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Defines a variant type with 3 unary constructors. We refer to each constructor as a "case". Cases are numbered consecutively starting at zero.

type ('a0, 'a1, 'a2) t =
  1. | Case0 of 'a0
  2. | Case1 of 'a1
  3. | Case2 of 'a2
include Ppx_compare_lib.Comparable.S3 with type ('a0, 'a1, 'a2) t := ('a0, 'a1, 'a2) t
val compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('c -> 'c -> int) -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> int
include Ppx_compare_lib.Equal.S3 with type ('a0, 'a1, 'a2) t := ('a0, 'a1, 'a2) t
val equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> ('c -> 'c -> bool) -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> bool
include Ppx_hash_lib.Hashable.S3 with type ('a0, 'a1, 'a2) t := ('a0, 'a1, 'a2) t
val hash_fold_t : (Base.Hash.state -> 'a -> Base.Hash.state) -> (Base.Hash.state -> 'b -> Base.Hash.state) -> (Base.Hash.state -> 'c -> Base.Hash.state) -> Base.Hash.state -> ('a, 'b, 'c) t -> Base.Hash.state
val sexp_of_t : ('a0 -> Sexplib0.Sexp.t) -> ('a1 -> Sexplib0.Sexp.t) -> ('a2 -> Sexplib0.Sexp.t) -> ('a0, 'a1, 'a2) t -> Sexplib0.Sexp.t

Constructors

val case0 : 'a -> ('a, _, _) t
val case1 : 'a -> (_, 'a, _) t
val case2 : 'a -> (_, _, 'a) t

Predicates

val is_case0 : (_, _, _) t -> Base.bool
val is_case1 : (_, _, _) t -> Base.bool
val is_case2 : (_, _, _) t -> Base.bool

Accessors

val get_case0 : ('a, _, _) t -> 'a Base.option
val get_case1 : (_, 'a, _) t -> 'a Base.option
val get_case2 : (_, _, 'a) t -> 'a Base.option

Accessors that raise

val get_case0_exn : ('a, _, _) t -> 'a
val get_case1_exn : (_, 'a, _) t -> 'a
val get_case2_exn : (_, _, 'a) t -> 'a
val map : ('a0, 'a1, 'a2) t -> f0:('a0 -> 'b0) -> f1:('a1 -> 'b1) -> f2:('a2 -> 'b2) -> ('b0, 'b1, 'b2) t

Map all cases

Map individual cases

val map_case0 : ('b, 'a1, 'a2) t -> f:('b -> 'c) -> ('c, 'a1, 'a2) t
val map_case1 : ('a0, 'b, 'a2) t -> f:('b -> 'c) -> ('a0, 'c, 'a2) t
val map_case2 : ('a0, 'a1, 'b) t -> f:('b -> 'c) -> ('a0, 'a1, 'c) t