Make.Either
Either type.
Either is the simplest and most generic sum/variant type: a value of ('a, 'b) Either.t
is either a Left (v : 'a)
or a Right (v : 'b)
.
It is a natural choice in the API of generic functions where values could fall in two different cases, possibly at different types, without assigning a specific meaning to what each case should be.
For example:
List.partition_map:
('a -> ('b, 'c) Either.t) -> 'a list -> 'b list * 'c list
If you are looking for a parametrized type where one alternative means success and the other means failure, you should use the more specific type Result.t
.
A value of ('a, 'b) Either.t
contains either a value of 'a
or a value of 'b
equal ~left ~right e0 e1
tests equality of e0
and e1
using left
and right
to respectively compare values wrapped by Left _
and Right _
.