@@ -49,6 +49,7 @@ module Squeal.PostgreSQL.PG
4949 , Bound (..)
5050 , pattern Closed
5151 , pattern Open
52+ , (<=..<=), (<..<), (<=..<), (<..<=)
5253 -- * Type families
5354 , LabelsPG
5455 , DimPG
@@ -378,3 +379,19 @@ pattern Closed, Open :: Maybe x -> Bound x
378379pattern Closed x = Bound True x
379380pattern Open x = Bound False x
380381type 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)