@@ -13,6 +13,25 @@ import Rel8.Query ( Query )
1313import Rel8.Query.Filter ( where_ )
1414
1515
16+-- | Filter a 'Query' that might return @null@ to a 'Query' without any
17+-- @null@s.
18+--
19+-- Corresponds to 'Data.Maybe.catMaybes'.
20+--
21+-- >>> select c $ pure (nullExpr :: Expr (Maybe Bool))
22+-- [Nothing]
23+--
24+-- >>> select c $ catNullable (nullExpr :: Expr (Maybe Bool))
25+-- []
26+--
27+-- >>> select c $ catNullable (lit (Just True))
28+-- [True]
29+--
30+-- Notice how in the last example a @Bool@ is returned (rather than @Maybe
31+-- Bool@):
32+--
33+-- >>> :t catNullable (lit (Just True))
34+-- catMaybe (lit (Just True)) :: Query (Expr Bool)
1635catNullable :: Expr (Maybe a) -> Query (Expr a)
1736catNullable a = do
1837 where_ $ isNonNull a