[Haskell-cafe] guards in applicative style
tifonzafel at gmail.com
Wed Sep 12 16:40:11 CEST 2012
Suppose I have two list and I want to calculate
the cartesian product between the two of them,
constrained to a predicate.
In List comprehension notation is just
result = [ (x, y) | x <- list1, y <-list2, somePredicate x y ]
or in monadic notation
result = do
x <- list1
y <- list2
guard (somePredicate x y)
return $ (x,y)
Then I was wondering if we can do something similar using an applicative
result = (,) <$> list1 <*> list2 (somePredicate ???)
The question is then,
there is a way for defining a guard in applicative Style?
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe