on dev help sign in
range operators & functions
84df501Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+3−3
@@ -353,10 +353,10 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
353 atanh x = log ((1 + x) / (1 - x)) / 2
353 atanh x = log ((1 + x) / (1 - x)) / 2
354
354
355-- | Contained by operators
355-- | Contained by operators
356−class PGSubset container where
356+class PGSubset subset where
357− (@>) :: Operator (null0 container) (null1 container) ('Null 'PGbool)
357+ (@>) :: Operator (null0 subset) (null1 subset) ('Null 'PGbool)
358 (@>) = unsafeBinaryOp "@>"
358 (@>) = unsafeBinaryOp "@>"
359− (<@) :: Operator (null0 container) (null1 container) ('Null 'PGbool)
359+ (<@) :: Operator (null0 subset) (null1 subset) ('Null 'PGbool)
360 (<@) = unsafeBinaryOp "<@"
360 (<@) = unsafeBinaryOp "<@"
361instance PGSubset 'PGjsonb
361instance PGSubset 'PGjsonb
362instance PGSubset 'PGtsquery
362instance PGSubset 'PGtsquery
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Range.hs+77
@@ -39,6 +39,25 @@ module Squeal.PostgreSQL.Expression.Range
39 , singleton, whole
39 , singleton, whole
40 , Bound (..)
40 , Bound (..)
41 , closed, open
41 , closed, open
42+ , (<@.)
43+ , (@>.)
44+ , (&&.)
45+ , (<<.)
46+ , (>>.)
47+ , (&<.)
48+ , (&>.)
49+ , (=|=.)
50+ , (+.)
51+ , (*.)
52+ , (-.)
53+ , lowerBound
54+ , upperBound
55+ , isEmpty
56+ , lowerInc
57+ , lowerInf
58+ , upperInc
59+ , upperInf
60+ , rangeMerge
42 ) where
61 ) where
43
62
44import Data.Bool
63import Data.Bool
@@ -112,3 +131,61 @@ singleton x = x <=..<= x
112
131
113whole :: Range x
132whole :: Range x
114whole = NonEmpty (open Nothing) (open Nothing)
133whole = NonEmpty (open Nothing) (open Nothing)
134+
135+(<@.) :: Operator ('NotNull ty) (null ('PGrange ty)) ('Null 'PGbool)
136+(<@.) = unsafeBinaryOp "<@"
137+
138+(@>.) :: Operator (null ('PGrange ty)) ('NotNull ty) ('Null 'PGbool)
139+(@>.) = unsafeBinaryOp "<@"
140+
141+(&&.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
142+(&&.) = unsafeBinaryOp "&&"
143+
144+(<<.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
145+(<<.) = unsafeBinaryOp "<<"
146+
147+(>>.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
148+(>>.) = unsafeBinaryOp ">>"
149+
150+(&<.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
151+(&<.) = unsafeBinaryOp "&<"
152+
153+(&>.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
154+(&>.) = unsafeBinaryOp "&>"
155+
156+(=|=.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
157+(=|=.) = unsafeBinaryOp "&>"
158+
159+(+.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
160+(+.) = unsafeBinaryOp "+"
161+
162+(*.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
163+(*.) = unsafeBinaryOp "*"
164+
165+(-.) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
166+(-.) = unsafeBinaryOp "-"
167+
168+lowerBound :: null ('PGrange ty) :--> null ty
169+lowerBound = unsafeFunction "lower"
170+
171+upperBound :: null ('PGrange ty) :--> null ty
172+upperBound = unsafeFunction "upper"
173+
174+isEmpty :: null ('PGrange ty) :--> 'Null 'PGbool
175+isEmpty = unsafeFunction "isempty"
176+
177+lowerInc :: null ('PGrange ty) :--> 'Null 'PGbool
178+lowerInc = unsafeFunction "lower_inc"
179+
180+lowerInf :: null ('PGrange ty) :--> 'Null 'PGbool
181+lowerInf = unsafeFunction "lower_inf"
182+
183+upperInc :: null ('PGrange ty) :--> 'Null 'PGbool
184+upperInc = unsafeFunction "upper_inc"
185+
186+upperInf :: null ('PGrange ty) :--> 'Null 'PGbool
187+upperInf = unsafeFunction "upper_inf"
188+
189+rangeMerge :: FunctionN
190+ '[ null ('PGrange ty), null ('PGrange ty)] (null ('PGrange ty))
191+rangeMerge = unsafeFunctionN "range_merge"