[Haskell-cafe] Error Monad and strings
Antoine Latter
aslatter at gmail.com
Tue Jul 27 21:47:21 EDT 2010
On Tue, Jul 27, 2010 at 6:29 PM, Dietrich Epp <depp at zdome.net> wrote:
> I'll say yes, a pattern match failure is a bug. This is one of the great
> debates in the language: whether all pattern matching code should be
> guaranteed complete at compile time or not. However, any function you call
> which returns a result in your monad could theoretically call "fail" if it
> was written that way. Data.Map.lookup used to call "fail" when it could not
> find a key, but that got changed.
I've always thought that being able to write:
> catMaybes :: [Maybe a] -> [a]
> catMaybes xs = [ x | Just x <- xs ]
is really cool, which relies on:
> fail _ = []
being in the Monad instance for List.
But I would give that up for getting "fail" out of Monad. We can alway
re-implement "catMaybes."
Antoine
More information about the Haskell-Cafe
mailing list