[Haskell-beginners] short-circuit like Maybe monad with a difference

Dennis Raddle dennis.raddle at gmail.com
Fri Sep 30 20:56:03 UTC 2016


I just tried something



evalRules :: [Rule] -> Step -> [Double]
evalRules rules step = catMaybes . takeWhile isJust . map (flip evalRule
step) $ rules

This seems to work according to my testing.



On Fri, Sep 30, 2016 at 1:32 PM, Imants Cekusins <imantc at gmail.com> wrote:

> > short-circuits the computation if it hits Nothing. However, unlike the
> way the Maybe monad works, I want to know the partial results.
>> could store partial results in a State monad.. Maybe would short circuit
> but the values would stay in the State.
>
> would this work?
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160930/955100be/attachment.html>


More information about the Beginners mailing list