[Haskell-cafe] Splitting off many/some from Alternative

Gregory Crosswhite gcrosswhite at gmail.com
Thu Dec 15 03:56:38 CET 2011


On Dec 15, 2011, at 12:36 PM, Antoine Latter wrote:

> Although I'm still not sure why I would be using these operations in
> maybe or list.

You probably wouldn't use these operations directly on Maybe or List, but the whole point is that when you are using a typeclass you have cannot assume that you know what they underlying type is.  If your algorithm needs to make use of many and some, then as long as the type is an instance of Alternative then you know that you can do this regardless of what the type actually is.  If certain types break your algorithm, then the constraint on the type being Alternative is clearly insufficient.

I wish that I had a more concrete example of how this could happen in practice off the top of my head --- say, when writing something like an alternative stack transformer (analogous to a monad stack transformer).

Cheers,
Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111215/a6c57350/attachment.htm>


More information about the Haskell-Cafe mailing list