on dev help sign in
Range
c2d4fa8Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/PG.hs+17
@@ -49,6 +49,7 @@ module Squeal.PostgreSQL.PG
49 , Bound (..)
49 , Bound (..)
50 , pattern Closed
50 , pattern Closed
51 , pattern Open
51 , pattern Open
52+ , (<=..<=), (<..<), (<=..<), (<..<=)
52 -- * Type families
53 -- * Type families
53 , LabelsPG
54 , LabelsPG
54 , DimPG
55 , DimPG
@@ -378,3 +379,19 @@ pattern Closed, Open :: Maybe x -> Bound x
378pattern Closed x = Bound True x
379pattern Closed x = Bound True x
379pattern Open x = Bound False x
380pattern Open x = Bound False x
380type instance PG (Bound x, Bound x) = 'PGrange (PG x)
381type instance PG (Bound x, Bound x) = 'PGrange (PG x)
382+
383+data Range x
384+ = Empty
385+ | NonEmpty (Bound x) (Bound x)
386+ deriving
387+ ( Eq, Ord, Show, Read, GHC.Generic
388+ , Functor, Foldable, Traversable )
389+-- instance RenderSQL x => RenderSQL
390+(<=..<=), (<..<), (<=..<), (<..<=) :: x -> x -> Range x
391+x <=..<= y = NonEmpty (Closed (Just x)) (Closed (Just y))
392+x <..< y = NonEmpty (Open (Just x)) (Open (Just y))
393+x <=..< y = NonEmpty (Closed (Just x)) (Open (Just y))
394+x <..<= y = NonEmpty (Open (Just x)) (Closed (Just y))
395+pattern Above, Below :: Bound x -> Range x
396+pattern Above x = NonEmpty (Open Nothing) x
397+pattern Below x = NonEmpty x (Open Nothing)