Great essay, but I’d change the title to reflect that it’s the Foldable instances for these that are not arbitrary. When I saw the title, I was expecting something on Arbitrary (as in QuickCheck).
These instances are confusing only if people are unaware of what (,) means in the container context. A pair is versatile, but as a container (or Functor), the type (a, b) means, unambiguously, “a container of exactly one b with an annotation of type a”. And Either a b means “a container of zero or one b”– just as Maybe is a container– with an annotation of type a in the “zero” case. That’s obviously a clumsy-sounding way to describe what we don’t usually think of as a container, but it’s the only “right” interpretation, given the curried type signatures and the fact that Functor is by definition of one type.
Great essay, but I’d change the title to reflect that it’s the
Foldableinstances for these that are not arbitrary. When I saw the title, I was expecting something onArbitrary(as in QuickCheck).These instances are confusing only if people are unaware of what
(,)means in the container context. A pair is versatile, but as a container (orFunctor), the type(a, b)means, unambiguously, “a container of exactly onebwith an annotation of typea”. AndEither a bmeans “a container of zero or oneb”– just asMaybeis a container– with an annotation of typeain the “zero” case. That’s obviously a clumsy-sounding way to describe what we don’t usually think of as a container, but it’s the only “right” interpretation, given the curried type signatures and the fact thatFunctoris by definition of one type.