generalization of maybeToList

Conor McBride conor at
Wed Feb 15 10:30:54 CET 2012

On 15 Feb 2012, at 01:03, Jeff Shaw wrote:

> If we want to argue about maybeTo and the Fairbairn threshold, probably we should argue about whether to include maybeToList, which is less general than maybeTo.

and only a fraction shorter than

  foldMap pure

or, as it is in the Epigram codebase

  trail :: (Applicative f, Foldable t, Monoid (f a)) => t a -> f a
  trail = foldMap pure

"a trail told by an idiom..." being the joke at the time.

It would do listToMaybe as well, if the Monoid instance for Maybe
captured the prioritized choice semantics.

It would be interesting to apply the Fairbairn threshold retrospectively
and see what could be cheaply replaced by suitable deployment of
Applicative/Traversable/Foldable/Monoid and (crucially) Control.Newtype.
Instead of remembering lots of names of functions, get types to remember
things for you! Or something.

Gotta run


More information about the Libraries mailing list