Hi Haskellers,<div><br></div><div>Suppose I have two list and I want to calculate</div><div>the cartesian product between the two of them,</div><div>constrained to a predicate.</div><div>In List comprehension notation is just</div>
<div><br></div><div>result = [ (x, y) | x &lt;- list1, y &lt;-list2, somePredicate x y ]</div><div><br></div><div>or in monadic notation</div><div><br></div><div>result = do</div><div> x &lt;- list1 </div><div> y &lt;- list2</div>
<div> guard (somePredicate x y)</div><div>return $ (x,y)</div><div><br></div><div>Then I was wondering if we can do something similar using an applicative style</div><div><br></div><div>result = (,) &lt;$&gt; list1 &lt;*&gt; list2 (somePredicate ???)</div>
<div><br></div><div>The question is then, </div><div>there is a way for defining a guard in applicative Style? </div><div><br></div><div>Thanks in advance,</div><div><br></div><div>Felipe Zapata.</div><div><br></div><div>
<br></div>