<div><div>Good Morning, <br></div><div><div><br></div></div><div>I currently want to write a search algorithm with 3 end conditions:<br></div><div>a) Solution Found <br></div><div>b) N-iterations done <br></div><div>c) x minutes timeout<br></div><div><div><br></div></div><div>I would like to split the function in two pieces, one which is pure with a seed and no timeout, and one time-outed in a monad (IO?).<br></div><div>So <br></div><div>pureSearch :: Seed -> Iterations -> Maybe Result <br></div><div>and <br></div><div>search :: Timeout -> Seed -> Iterations -> IO Maybe Result<br></div><div><div><br></div></div><div><div>Is this a known Pattern? <br></div><div>Do you know good examples for this behavior? <br></div></div><div>Any other recommendations before I start implementing? <br></div><div><div><br></div></div><div>Best<br></div><div>Leonhard<br></div><div> <br></div><div class="protonmail_signature_block protonmail_signature_block-empty"><div class="protonmail_signature_block-user protonmail_signature_block-empty"><div><br></div></div><div class="protonmail_signature_block-proton protonmail_signature_block-empty"><div><br></div></div></div><div><div><br></div></div></div><div><br></div>