Eliminate/move class Alternative

Ross Paterson ross at soi.city.ac.uk
Thu Apr 30 08:29:43 EDT 2009

On Sun, Mar 15, 2009 at 11:50:15PM +0100, Ben Franksen wrote:
> I propose to remove class Alternative and functions depending on it
> (optional, some, and many) from Control.Applicative. They can be moved into
> a separate module Control.Alternative if people desire such a class, but I
> doubt that it has many useful applications, at least in its present form.

In my opinion, the "killer app" for Alternative is "Parsing Permutation
Phrases", by Arthur Baars, Andres Loeh and S. Doaitse Swierstra, Haskell
Workshop 2001.  I've just uploaded a package action-permutations based
on this.

> Rationale:
> Although the idea behind Alternative, i.e. generalize some of the functions
> commonly found in parser combinator libs, is a nice one, it doesn't work
> too well in practice, /even/ for the case that has inspired it (namely
> parsers).
> This is mostly due to the class method 'empty'.
> [...]
> Second, and more important, is that some parser libs would like to, but
> cannot offer a sensible implementation for it. For instance, any
> error-correcting library of parser combinators (like those invented by
> Swierstra & Duponcheel) need to construct a valid result even in case of a
> failed parse.

That's odd: I thought all of Doaitse's parsers had pFail :: p a.

More information about the Libraries mailing list