Probably more suited for the
#arrow channel but I’ll give it a go 😛
Pair
is a tuple with no info about what
first
and
second
mean. See “tuples obfuscate” in the Google Guava ideas graveyard:
https://github.com/google/guava/wiki/IdeaGraveyard
Either
is an abstraction built for modelling the common scenario where an operation can succeed or fail, with failure represented by
left
and success represented by
right
. This can be an alternative to declaring functions that have a return type for success but rely on throwing exceptions to indicate failure.
Either
provides functions like
fold
,
flatMap
etc. that allow chaining operations, and even a comprehension that allows writing imperative code in a block without using
flatMap
etc.
TL;DR
Pair
is very broad and
Either
is suited to a specific use case