[Haskell-beginners] Calculations that might fail: with arrays

Antoine Latter aslatter at gmail.com
Thu Jun 9 03:56:54 CEST 2011

Have you tried 'mapM' from the module Control.Monad?
On Jun 8, 2011 7:10 PM, "Christopher Howard" <
christopher.howard at frigidcode.com> wrote:
> I was wondering if there was a stock function or package in Haskell that
> allows you to map over a list, but short-circuits the mapping if any of
> the calculations fail. Say, something like this:
> -- Don't know if this is a valid signature! :)
> mapThatCanFail :: (b -> Either a b) -> [b] -> Either a [b]
> The idea being that, if any calculations fail, the function doesn't
> bother mapping the rest of the list, but just returns a Left value
> (error). Otherwise, it returns a Right value containing the new list.
> I suppose I could try to implement that myself, but it seems like the
> sort of thing that someone would have thought of already.
> --
> frigidcode.com
> theologia.indicium.us
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110608/444629c9/attachment.htm>

More information about the Beginners mailing list