@@ -1,5 +1,6 @@
11{-# LANGUAGE
22 OverloadedStrings
3+ , RankNTypes
34 , TypeInType
45 , TypeOperators
56#-}
@@ -13,6 +14,7 @@ module Squeal.PostgreSQL.Expression.Comparison
1314 , (.>)
1415 , greatest
1516 , least
17+ , BetweenExpr
1618 , between
1719 , notBetween
1820 , betweenSymmetric
@@ -85,25 +87,24 @@ greatest = unsafeFunctionVar "GREATEST"
8587least :: FunctionVar ty ty ty
8688least = unsafeFunctionVar "LEAST"
8789
88−{- | >>> printSQL $ true `between` (null_, false)
89−TRUE BETWEEN NULL AND FALSE
90−-}
91−between
92− :: Expression outer commons grp schemas params from (null ty)
90+type BetweenExpr
91+ = forall outer commons grp schemas params from null ty
92+ . Expression outer commons grp schemas params from (null ty)
9393 -> ( Expression outer commons grp schemas params from (null ty)
9494 , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
9595 -> Condition outer commons grp schemas params from
96+
97+{- | >>> printSQL $ true `between` (null_, false)
98+TRUE BETWEEN NULL AND FALSE
99+-}
100+between :: BetweenExpr
96101between a (x,y) = UnsafeExpression $ renderSQL a <+> "BETWEEN"
97102 <+> renderSQL x <+> "AND" <+> renderSQL y
98103
99104{- | >>> printSQL $ true `notBetween` (null_, false)
100105TRUE NOT BETWEEN NULL AND FALSE
101106-}
102−notBetween
103− :: Expression outer commons grp schemas params from (null ty)
104− -> ( Expression outer commons grp schemas params from (null ty)
105− , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
106− -> Condition outer commons grp schemas params from
107+notBetween :: BetweenExpr
107108notBetween a (x,y) = UnsafeExpression $ renderSQL a <+> "NOT BETWEEN"
108109 <+> renderSQL x <+> "AND" <+> renderSQL y
109110
@@ -112,11 +113,7 @@ notBetween a (x,y) = UnsafeExpression $ renderSQL a <+> "NOT BETWEEN"
112113>>> printSQL $ true `betweenSymmetric` (null_, false)
113114TRUE BETWEEN SYMMETRIC NULL AND FALSE
114115-}
115−betweenSymmetric
116− :: Expression outer commons grp schemas params from (null ty)
117− -> ( Expression outer commons grp schemas params from (null ty)
118− , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
119− -> Condition outer commons grp schemas params from
116+betweenSymmetric :: BetweenExpr
120117betweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
121118 <+> "BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
122119
@@ -125,11 +122,7 @@ betweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
125122>>> printSQL $ true `notBetweenSymmetric` (null_, false)
126123TRUE NOT BETWEEN SYMMETRIC NULL AND FALSE
127124-}
128−notBetweenSymmetric
129− :: Expression outer commons grp schemas params from (null ty)
130− -> ( Expression outer commons grp schemas params from (null ty)
131− , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
132− -> Condition outer commons grp schemas params from
125+notBetweenSymmetric :: BetweenExpr
133126notBetweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
134127 <+> "NOT BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
135128