Standard Either type like in Haskell

Is there one? If there is, how to access and use it? If there isn’t, is there some kind of third party library containing it?

Yes, the following type is now standard since 4.03.0 (released in April 2016):

type ('a, 'b) result = Ok of 'a | Error of 'b

It is not as agnostic as left/right, so it might be better to redefine your own for certain usages


Base also has an Either type that is less opinionated about the
meaning of the two variants: