A type that stores one of two values.

data Either a b
  = Left a
  | Right b
PackageType name"Plain English" name
purescript-eitherEither a bChoice of 2 types
UsageValues & their Usage
Used to indicate one type or a second type
  • Left a - a value of a
  • Right b - a value of b
Error handing (when we care about the error)
  • Left a - the error type that is returned when a computation fails
  • Right b - the output type when a computation succeeds

API visualized:

Either API

For the corresponding "open" type, see Variant

PackageType name"Plain English" name
purescript-variantVariant (a :: A, b :: B)Choice of N types