@@ -20,6 +20,13 @@ import Rel8.Query ( Query )
20import Rel8.Query.Opaleye ( fromOpaleye )
20import Rel8.Query.Opaleye ( fromOpaleye )
23+-- | @filter f x@ will be a zero-row query when @f x@ is @False@, and will
24+-- return @x@ unchanged when @f x@ is @True@. This is similar to
25+-- 'Control.Monad.guard', but as the predicate is separate from the argument,
26+-- it is easy to use in a pipeline of 'Query' transformations.
28+-- >>> select c $ values [ lit x | x <- [ 1..5 :: Int32 ] ] >>= filter (>. 3)
23filter :: (a -> Expr Bool) -> a -> Query a
30filter :: (a -> Expr Bool) -> a -> Query a
24filter f a = a <$ where_ (f a)
31filter f a = a <$ where_ (f a)