<div dir="ltr">I have a function 'evalRule' that applies rules to steps in a backtracking search optimization problem and evaluates the step's fitness or decides that it must be eliminated entirely. <div><br></div><div>In the following, a result of Nothing means "eliminate the step," Just x means the step has fitness score x.</div><div><br></div><div>evalRule :: Rule -> Step -> Maybe Double</div><div><br></div><div>I would like to write a function that applies a bunch of rules but short-circuits the computation if it hits Nothing. However, unlike the way the Maybe monad works, I want to know the partial results.</div><div><br></div><div>In the following, the rules are applied in order and the "Just" results are collected up the point where a rule returns Nothing.</div><div><br></div><div>evalRules :: [Rule] -> Step -> [Double]</div><div><br></div><div>What's a nice way to do this?</div><div><br></div><div>D</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>