{-# LANGUAGE
AllowAmbiguousTypes
, DataKinds
, DeriveAnyClass
, DeriveGeneric
, DeriveFoldable
, DerivingStrategies
, DeriveTraversable
, FlexibleContexts
, FlexibleInstances
, LambdaCase
, MultiParamTypeClasses
, OverloadedLabels
, OverloadedStrings
, PatternSynonyms
, RankNTypes
, ScopedTypeVariables
, TypeApplications
, TypeFamilies
, TypeOperators
, UndecidableInstances
#-}
module Squeal.PostgreSQL.Expression.Range
(
Range (..)
, (<=..<=), (<..<), (<=..<), (<..<=)
, moreThan, atLeast, lessThan, atMost
, singleton, whole
, Bound (..)
, range
, (.<@)
, (@>.)
, (<<@)
, (@>>)
, (&<)
, (&>)
, (-|-)
, (@+)
, (@*)
, (@-)
, lowerBound
, upperBound
, isEmpty
, lowerInc
, lowerInf
, upperInc
, upperInf
, rangeMerge
) where
import qualified GHC.Generics as GHC
import qualified Generics.SOP as SOP
import Squeal.PostgreSQL.Expression
import Squeal.PostgreSQL.Expression.Type hiding (bool)
import Squeal.PostgreSQL.Type.PG
import Squeal.PostgreSQL.Render
import Squeal.PostgreSQL.Type.Schema
range
:: TypeExpression db (null ('PGrange ty))
-> Range (Expression grp lat with db params from ('NotNull ty))
-> Expression grp lat with db params from (null ('PGrange ty))
range :: TypeExpression db (null ('PGrange ty))
-> Range (Expression grp lat with db params from ('NotNull ty))
-> Expression grp lat with db params from (null ('PGrange ty))
range TypeExpression db (null ('PGrange ty))
ty = \case
Range (Expression grp lat with db params from ('NotNull ty))
Empty -> ByteString
-> Expression grp lat with db params from (null ('PGrange ty))
forall (grp :: Grouping) (lat :: FromType) (with :: FromType)
(db :: SchemasType) (params :: [NullType]) (from :: FromType)
(ty :: NullType).
ByteString -> Expression grp lat with db params from ty
UnsafeExpression (ByteString
-> Expression grp lat with db params from (null ('PGrange ty)))
-> ByteString
-> Expression grp lat with db params from (null ('PGrange ty))
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString
parenthesized
(ByteString
emp ByteString -> ByteString -> ByteString
<+> ByteString
"::" ByteString -> ByteString -> ByteString
<+> TypeExpression db (null ('PGrange ty)) -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL TypeExpression db (null ('PGrange ty))
ty)
NonEmpty Bound (Expression grp lat with db params from ('NotNull ty))
l Bound (Expression grp lat with db params from ('NotNull ty))
u -> ByteString
-> Expression grp lat with db params from (null ('PGrange ty))
forall (grp :: Grouping) (lat :: FromType) (with :: FromType)
(db :: SchemasType) (params :: [NullType]) (from :: FromType)
(ty :: NullType).
ByteString -> Expression grp lat with db params from ty
UnsafeExpression (ByteString
-> Expression grp lat with db params from (null ('PGrange ty)))
-> ByteString
-> Expression grp lat with db params from (null ('PGrange ty))
forall a b. (a -> b) -> a -> b
$ TypeExpression db (null ('PGrange ty)) -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL TypeExpression db (null ('PGrange ty))
ty ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString -> ByteString
parenthesized
([ByteString] -> ByteString
commaSeparated (Bound (Expression grp lat with db params from ('NotNull ty))
-> Bound (Expression grp lat with db params from ('NotNull ty))
-> [ByteString]
args Bound (Expression grp lat with db params from ('NotNull ty))
l Bound (Expression grp lat with db params from ('NotNull ty))
u))
where
emp :: ByteString
emp = ByteString
singleQuote ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
"empty" ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
singleQuote
args :: Bound (Expression grp lat with db params from ('NotNull ty))
-> Bound (Expression grp lat with db params from ('NotNull ty))
-> [ByteString]
args Bound (Expression grp lat with db params from ('NotNull ty))
l Bound (Expression grp lat with db params from ('NotNull ty))
u = [Bound (Expression grp lat with db params from ('NotNull ty))
-> ByteString
arg Bound (Expression grp lat with db params from ('NotNull ty))
l, Bound (Expression grp lat with db params from ('NotNull ty))
-> ByteString
arg Bound (Expression grp lat with db params from ('NotNull ty))
u, ByteString
singleQuote ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> Bound (Expression grp lat with db params from ('NotNull ty))
-> ByteString
forall x. Bound x -> ByteString
bra Bound (Expression grp lat with db params from ('NotNull ty))
l ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> Bound (Expression grp lat with db params from ('NotNull ty))
-> ByteString
forall x. Bound x -> ByteString
ket Bound (Expression grp lat with db params from ('NotNull ty))
u ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
singleQuote]
singleQuote :: ByteString
singleQuote = ByteString
"\'"
arg :: Bound (Expression grp lat with db params from ('NotNull ty))
-> ByteString
arg = \case
Bound (Expression grp lat with db params from ('NotNull ty))
Infinite -> ByteString
"NULL"; Closed Expression grp lat with db params from ('NotNull ty)
x -> Expression grp lat with db params from ('NotNull ty) -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL Expression grp lat with db params from ('NotNull ty)
x; Open Expression grp lat with db params from ('NotNull ty)
x -> Expression grp lat with db params from ('NotNull ty) -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL Expression grp lat with db params from ('NotNull ty)
x
bra :: Bound x -> ByteString
bra = \case Bound x
Infinite -> ByteString
"("; Closed x
_ -> ByteString
"["; Open x
_ -> ByteString
"("
ket :: Bound x -> ByteString
ket = \case Bound x
Infinite -> ByteString
")"; Closed x
_ -> ByteString
"]"; Open x
_ -> ByteString
")"
data Bound x
= Infinite
| Closed x
| Open x
deriving
( Bound x -> Bound x -> Bool
(Bound x -> Bound x -> Bool)
-> (Bound x -> Bound x -> Bool) -> Eq (Bound x)
forall x. Eq x => Bound x -> Bound x -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Bound x -> Bound x -> Bool
$c/= :: forall x. Eq x => Bound x -> Bound x -> Bool
== :: Bound x -> Bound x -> Bool
$c== :: forall x. Eq x => Bound x -> Bound x -> Bool
Eq, Eq (Bound x)
Eq (Bound x)
-> (Bound x -> Bound x -> Ordering)
-> (Bound x -> Bound x -> Bool)
-> (Bound x -> Bound x -> Bool)
-> (Bound x -> Bound x -> Bool)
-> (Bound x -> Bound x -> Bool)
-> (Bound x -> Bound x -> Bound x)
-> (Bound x -> Bound x -> Bound x)
-> Ord (Bound x)
Bound x -> Bound x -> Bool
Bound x -> Bound x -> Ordering
Bound x -> Bound x -> Bound x
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall x. Ord x => Eq (Bound x)
forall x. Ord x => Bound x -> Bound x -> Bool
forall x. Ord x => Bound x -> Bound x -> Ordering
forall x. Ord x => Bound x -> Bound x -> Bound x
min :: Bound x -> Bound x -> Bound x
$cmin :: forall x. Ord x => Bound x -> Bound x -> Bound x
max :: Bound x -> Bound x -> Bound x
$cmax :: forall x. Ord x => Bound x -> Bound x -> Bound x
>= :: Bound x -> Bound x -> Bool
$c>= :: forall x. Ord x => Bound x -> Bound x -> Bool
> :: Bound x -> Bound x -> Bool
$c> :: forall x. Ord x => Bound x -> Bound x -> Bool
<= :: Bound x -> Bound x -> Bool
$c<= :: forall x. Ord x => Bound x -> Bound x -> Bool
< :: Bound x -> Bound x -> Bool
$c< :: forall x. Ord x => Bound x -> Bound x -> Bool
compare :: Bound x -> Bound x -> Ordering
$ccompare :: forall x. Ord x => Bound x -> Bound x -> Ordering
$cp1Ord :: forall x. Ord x => Eq (Bound x)
Ord, Int -> Bound x -> ShowS
[Bound x] -> ShowS
Bound x -> String
(Int -> Bound x -> ShowS)
-> (Bound x -> String) -> ([Bound x] -> ShowS) -> Show (Bound x)
forall x. Show x => Int -> Bound x -> ShowS
forall x. Show x => [Bound x] -> ShowS
forall x. Show x => Bound x -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Bound x] -> ShowS
$cshowList :: forall x. Show x => [Bound x] -> ShowS
show :: Bound x -> String
$cshow :: forall x. Show x => Bound x -> String
showsPrec :: Int -> Bound x -> ShowS
$cshowsPrec :: forall x. Show x => Int -> Bound x -> ShowS
Show, ReadPrec [Bound x]
ReadPrec (Bound x)
Int -> ReadS (Bound x)
ReadS [Bound x]
(Int -> ReadS (Bound x))
-> ReadS [Bound x]
-> ReadPrec (Bound x)
-> ReadPrec [Bound x]
-> Read (Bound x)
forall x. Read x => ReadPrec [Bound x]
forall x. Read x => ReadPrec (Bound x)
forall x. Read x => Int -> ReadS (Bound x)
forall x. Read x => ReadS [Bound x]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Bound x]
$creadListPrec :: forall x. Read x => ReadPrec [Bound x]
readPrec :: ReadPrec (Bound x)
$creadPrec :: forall x. Read x => ReadPrec (Bound x)
readList :: ReadS [Bound x]
$creadList :: forall x. Read x => ReadS [Bound x]
readsPrec :: Int -> ReadS (Bound x)
$creadsPrec :: forall x. Read x => Int -> ReadS (Bound x)
Read, (forall x. Bound x -> Rep (Bound x) x)
-> (forall x. Rep (Bound x) x -> Bound x) -> Generic (Bound x)
forall x. Rep (Bound x) x -> Bound x
forall x. Bound x -> Rep (Bound x) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall x x. Rep (Bound x) x -> Bound x
forall x x. Bound x -> Rep (Bound x) x
$cto :: forall x x. Rep (Bound x) x -> Bound x
$cfrom :: forall x x. Bound x -> Rep (Bound x) x
GHC.Generic
, a -> Bound b -> Bound a
(a -> b) -> Bound a -> Bound b
(forall a b. (a -> b) -> Bound a -> Bound b)
-> (forall a b. a -> Bound b -> Bound a) -> Functor Bound
forall a b. a -> Bound b -> Bound a
forall a b. (a -> b) -> Bound a -> Bound b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Bound b -> Bound a
$c<$ :: forall a b. a -> Bound b -> Bound a
fmap :: (a -> b) -> Bound a -> Bound b
$cfmap :: forall a b. (a -> b) -> Bound a -> Bound b
Functor, Bound a -> Bool
(a -> m) -> Bound a -> m
(a -> b -> b) -> b -> Bound a -> b
(forall m. Monoid m => Bound m -> m)
-> (forall m a. Monoid m => (a -> m) -> Bound a -> m)
-> (forall m a. Monoid m => (a -> m) -> Bound a -> m)
-> (forall a b. (a -> b -> b) -> b -> Bound a -> b)
-> (forall a b. (a -> b -> b) -> b -> Bound a -> b)
-> (forall b a. (b -> a -> b) -> b -> Bound a -> b)
-> (forall b a. (b -> a -> b) -> b -> Bound a -> b)
-> (forall a. (a -> a -> a) -> Bound a -> a)
-> (forall a. (a -> a -> a) -> Bound a -> a)
-> (forall a. Bound a -> [a])
-> (forall a. Bound a -> Bool)
-> (forall a. Bound a -> Int)
-> (forall a. Eq a => a -> Bound a -> Bool)
-> (forall a. Ord a => Bound a -> a)
-> (forall a. Ord a => Bound a -> a)
-> (forall a. Num a => Bound a -> a)
-> (forall a. Num a => Bound a -> a)
-> Foldable Bound
forall a. Eq a => a -> Bound a -> Bool
forall a. Num a => Bound a -> a
forall a. Ord a => Bound a -> a
forall m. Monoid m => Bound m -> m
forall a. Bound a -> Bool
forall a. Bound a -> Int
forall a. Bound a -> [a]
forall a. (a -> a -> a) -> Bound a -> a
forall m a. Monoid m => (a -> m) -> Bound a -> m
forall b a. (b -> a -> b) -> b -> Bound a -> b
forall a b. (a -> b -> b) -> b -> Bound a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Bound a -> a
$cproduct :: forall a. Num a => Bound a -> a
sum :: Bound a -> a
$csum :: forall a. Num a => Bound a -> a
minimum :: Bound a -> a
$cminimum :: forall a. Ord a => Bound a -> a
maximum :: Bound a -> a
$cmaximum :: forall a. Ord a => Bound a -> a
elem :: a -> Bound a -> Bool
$celem :: forall a. Eq a => a -> Bound a -> Bool
length :: Bound a -> Int
$clength :: forall a. Bound a -> Int
null :: Bound a -> Bool
$cnull :: forall a. Bound a -> Bool
toList :: Bound a -> [a]
$ctoList :: forall a. Bound a -> [a]
foldl1 :: (a -> a -> a) -> Bound a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Bound a -> a
foldr1 :: (a -> a -> a) -> Bound a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Bound a -> a
foldl' :: (b -> a -> b) -> b -> Bound a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Bound a -> b
foldl :: (b -> a -> b) -> b -> Bound a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Bound a -> b
foldr' :: (a -> b -> b) -> b -> Bound a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Bound a -> b
foldr :: (a -> b -> b) -> b -> Bound a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Bound a -> b
foldMap' :: (a -> m) -> Bound a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Bound a -> m
foldMap :: (a -> m) -> Bound a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Bound a -> m
fold :: Bound m -> m
$cfold :: forall m. Monoid m => Bound m -> m
Foldable, Functor Bound
Foldable Bound
Functor Bound
-> Foldable Bound
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Bound a -> f (Bound b))
-> (forall (f :: * -> *) a.
Applicative f =>
Bound (f a) -> f (Bound a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Bound a -> m (Bound b))
-> (forall (m :: * -> *) a. Monad m => Bound (m a) -> m (Bound a))
-> Traversable Bound
(a -> f b) -> Bound a -> f (Bound b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Bound (m a) -> m (Bound a)
forall (f :: * -> *) a. Applicative f => Bound (f a) -> f (Bound a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Bound a -> m (Bound b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Bound a -> f (Bound b)
sequence :: Bound (m a) -> m (Bound a)
$csequence :: forall (m :: * -> *) a. Monad m => Bound (m a) -> m (Bound a)
mapM :: (a -> m b) -> Bound a -> m (Bound b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Bound a -> m (Bound b)
sequenceA :: Bound (f a) -> f (Bound a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Bound (f a) -> f (Bound a)
traverse :: (a -> f b) -> Bound a -> f (Bound b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Bound a -> f (Bound b)
$cp2Traversable :: Foldable Bound
$cp1Traversable :: Functor Bound
Traversable )
data Range x = Empty | NonEmpty (Bound x) (Bound x)
deriving
( Range x -> Range x -> Bool
(Range x -> Range x -> Bool)
-> (Range x -> Range x -> Bool) -> Eq (Range x)
forall x. Eq x => Range x -> Range x -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Range x -> Range x -> Bool
$c/= :: forall x. Eq x => Range x -> Range x -> Bool
== :: Range x -> Range x -> Bool
$c== :: forall x. Eq x => Range x -> Range x -> Bool
Eq, Eq (Range x)
Eq (Range x)
-> (Range x -> Range x -> Ordering)
-> (Range x -> Range x -> Bool)
-> (Range x -> Range x -> Bool)
-> (Range x -> Range x -> Bool)
-> (Range x -> Range x -> Bool)
-> (Range x -> Range x -> Range x)
-> (Range x -> Range x -> Range x)
-> Ord (Range x)
Range x -> Range x -> Bool
Range x -> Range x -> Ordering
Range x -> Range x -> Range x
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall x. Ord x => Eq (Range x)
forall x. Ord x => Range x -> Range x -> Bool
forall x. Ord x => Range x -> Range x -> Ordering
forall x. Ord x => Range x -> Range x -> Range x
min :: Range x -> Range x -> Range x
$cmin :: forall x. Ord x => Range x -> Range x -> Range x
max :: Range x -> Range x -> Range x
$cmax :: forall x. Ord x => Range x -> Range x -> Range x
>= :: Range x -> Range x -> Bool
$c>= :: forall x. Ord x => Range x -> Range x -> Bool
> :: Range x -> Range x -> Bool
$c> :: forall x. Ord x => Range x -> Range x -> Bool
<= :: Range x -> Range x -> Bool
$c<= :: forall x. Ord x => Range x -> Range x -> Bool
< :: Range x -> Range x -> Bool
$c< :: forall x. Ord x => Range x -> Range x -> Bool
compare :: Range x -> Range x -> Ordering
$ccompare :: forall x. Ord x => Range x -> Range x -> Ordering
$cp1Ord :: forall x. Ord x => Eq (Range x)
Ord, Int -> Range x -> ShowS
[Range x] -> ShowS
Range x -> String
(Int -> Range x -> ShowS)
-> (Range x -> String) -> ([Range x] -> ShowS) -> Show (Range x)
forall x. Show x => Int -> Range x -> ShowS
forall x. Show x => [Range x] -> ShowS
forall x. Show x => Range x -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Range x] -> ShowS
$cshowList :: forall x. Show x => [Range x] -> ShowS
show :: Range x -> String
$cshow :: forall x. Show x => Range x -> String
showsPrec :: Int -> Range x -> ShowS
$cshowsPrec :: forall x. Show x => Int -> Range x -> ShowS
Show, ReadPrec [Range x]
ReadPrec (Range x)
Int -> ReadS (Range x)
ReadS [Range x]
(Int -> ReadS (Range x))
-> ReadS [Range x]
-> ReadPrec (Range x)
-> ReadPrec [Range x]
-> Read (Range x)
forall x. Read x => ReadPrec [Range x]
forall x. Read x => ReadPrec (Range x)
forall x. Read x => Int -> ReadS (Range x)
forall x. Read x => ReadS [Range x]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Range x]
$creadListPrec :: forall x. Read x => ReadPrec [Range x]
readPrec :: ReadPrec (Range x)
$creadPrec :: forall x. Read x => ReadPrec (Range x)
readList :: ReadS [Range x]
$creadList :: forall x. Read x => ReadS [Range x]
readsPrec :: Int -> ReadS (Range x)
$creadsPrec :: forall x. Read x => Int -> ReadS (Range x)
Read, (forall x. Range x -> Rep (Range x) x)
-> (forall x. Rep (Range x) x -> Range x) -> Generic (Range x)
forall x. Rep (Range x) x -> Range x
forall x. Range x -> Rep (Range x) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall x x. Rep (Range x) x -> Range x
forall x x. Range x -> Rep (Range x) x
$cto :: forall x x. Rep (Range x) x -> Range x
$cfrom :: forall x x. Range x -> Rep (Range x) x
GHC.Generic
, a -> Range b -> Range a
(a -> b) -> Range a -> Range b
(forall a b. (a -> b) -> Range a -> Range b)
-> (forall a b. a -> Range b -> Range a) -> Functor Range
forall a b. a -> Range b -> Range a
forall a b. (a -> b) -> Range a -> Range b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Range b -> Range a
$c<$ :: forall a b. a -> Range b -> Range a
fmap :: (a -> b) -> Range a -> Range b
$cfmap :: forall a b. (a -> b) -> Range a -> Range b
Functor, Range a -> Bool
(a -> m) -> Range a -> m
(a -> b -> b) -> b -> Range a -> b
(forall m. Monoid m => Range m -> m)
-> (forall m a. Monoid m => (a -> m) -> Range a -> m)
-> (forall m a. Monoid m => (a -> m) -> Range a -> m)
-> (forall a b. (a -> b -> b) -> b -> Range a -> b)
-> (forall a b. (a -> b -> b) -> b -> Range a -> b)
-> (forall b a. (b -> a -> b) -> b -> Range a -> b)
-> (forall b a. (b -> a -> b) -> b -> Range a -> b)
-> (forall a. (a -> a -> a) -> Range a -> a)
-> (forall a. (a -> a -> a) -> Range a -> a)
-> (forall a. Range a -> [a])
-> (forall a. Range a -> Bool)
-> (forall a. Range a -> Int)
-> (forall a. Eq a => a -> Range a -> Bool)
-> (forall a. Ord a => Range a -> a)
-> (forall a. Ord a => Range a -> a)
-> (forall a. Num a => Range a -> a)
-> (forall a. Num a => Range a -> a)
-> Foldable Range
forall a. Eq a => a -> Range a -> Bool
forall a. Num a => Range a -> a
forall a. Ord a => Range a -> a
forall m. Monoid m => Range m -> m
forall a. Range a -> Bool
forall a. Range a -> Int
forall a. Range a -> [a]
forall a. (a -> a -> a) -> Range a -> a
forall m a. Monoid m => (a -> m) -> Range a -> m
forall b a. (b -> a -> b) -> b -> Range a -> b
forall a b. (a -> b -> b) -> b -> Range a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Range a -> a
$cproduct :: forall a. Num a => Range a -> a
sum :: Range a -> a
$csum :: forall a. Num a => Range a -> a
minimum :: Range a -> a
$cminimum :: forall a. Ord a => Range a -> a
maximum :: Range a -> a
$cmaximum :: forall a. Ord a => Range a -> a
elem :: a -> Range a -> Bool
$celem :: forall a. Eq a => a -> Range a -> Bool
length :: Range a -> Int
$clength :: forall a. Range a -> Int
null :: Range a -> Bool
$cnull :: forall a. Range a -> Bool
toList :: Range a -> [a]
$ctoList :: forall a. Range a -> [a]
foldl1 :: (a -> a -> a) -> Range a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Range a -> a
foldr1 :: (a -> a -> a) -> Range a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Range a -> a
foldl' :: (b -> a -> b) -> b -> Range a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Range a -> b
foldl :: (b -> a -> b) -> b -> Range a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Range a -> b
foldr' :: (a -> b -> b) -> b -> Range a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Range a -> b
foldr :: (a -> b -> b) -> b -> Range a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Range a -> b
foldMap' :: (a -> m) -> Range a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Range a -> m
foldMap :: (a -> m) -> Range a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Range a -> m
fold :: Range m -> m
$cfold :: forall m. Monoid m => Range m -> m
Foldable, Functor Range
Foldable Range
Functor Range
-> Foldable Range
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Range a -> f (Range b))
-> (forall (f :: * -> *) a.
Applicative f =>
Range (f a) -> f (Range a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Range a -> m (Range b))
-> (forall (m :: * -> *) a. Monad m => Range (m a) -> m (Range a))
-> Traversable Range
(a -> f b) -> Range a -> f (Range b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Range (m a) -> m (Range a)
forall (f :: * -> *) a. Applicative f => Range (f a) -> f (Range a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Range a -> m (Range b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Range a -> f (Range b)
sequence :: Range (m a) -> m (Range a)
$csequence :: forall (m :: * -> *) a. Monad m => Range (m a) -> m (Range a)
mapM :: (a -> m b) -> Range a -> m (Range b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Range a -> m (Range b)
sequenceA :: Range (f a) -> f (Range a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Range (f a) -> f (Range a)
traverse :: (a -> f b) -> Range a -> f (Range b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Range a -> f (Range b)
$cp2Traversable :: Foldable Range
$cp1Traversable :: Functor Range
Traversable )
deriving anyclass (All SListI (Code (Range x))
All SListI (Code (Range x))
-> (Range x -> Rep (Range x))
-> (Rep (Range x) -> Range x)
-> Generic (Range x)
Rep (Range x) -> Range x
Range x -> Rep (Range x)
forall x. All SListI (Code (Range x))
forall a.
All SListI (Code a) -> (a -> Rep a) -> (Rep a -> a) -> Generic a
forall x. Rep (Range x) -> Range x
forall x. Range x -> Rep (Range x)
to :: Rep (Range x) -> Range x
$cto :: forall x. Rep (Range x) -> Range x
from :: Range x -> Rep (Range x)
$cfrom :: forall x. Range x -> Rep (Range x)
$cp1Generic :: forall x. All SListI (Code (Range x))
SOP.Generic, Generic (Range x)
Generic (Range x)
-> (forall (proxy :: * -> *).
proxy (Range x) -> DatatypeInfo (Code (Range x)))
-> HasDatatypeInfo (Range x)
forall x. Generic (Range x)
forall a.
Generic a
-> (forall (proxy :: * -> *). proxy a -> DatatypeInfo (Code a))
-> HasDatatypeInfo a
forall x (proxy :: * -> *).
proxy (Range x) -> DatatypeInfo (Code (Range x))
forall (proxy :: * -> *).
proxy (Range x) -> DatatypeInfo (Code (Range x))
datatypeInfo :: proxy (Range x) -> DatatypeInfo (Code (Range x))
$cdatatypeInfo :: forall x (proxy :: * -> *).
proxy (Range x) -> DatatypeInfo (Code (Range x))
$cp1HasDatatypeInfo :: forall x. Generic (Range x)
SOP.HasDatatypeInfo)
instance IsPG hask => IsPG (Range hask) where
type PG (Range hask) = 'PGrange (PG hask)
(<=..<=), (<..<), (<=..<), (<..<=) :: x -> x -> Range x
infix 4 <=..<=, <..<, <=..<, <..<=
x
x <=..<= :: x -> x -> Range x
<=..<= x
y = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty (x -> Bound x
forall x. x -> Bound x
Closed x
x) (x -> Bound x
forall x. x -> Bound x
Closed x
y)
x
x <..< :: x -> x -> Range x
<..< x
y = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty (x -> Bound x
forall x. x -> Bound x
Open x
x) (x -> Bound x
forall x. x -> Bound x
Open x
y)
x
x <=..< :: x -> x -> Range x
<=..< x
y = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty (x -> Bound x
forall x. x -> Bound x
Closed x
x) (x -> Bound x
forall x. x -> Bound x
Open x
y)
x
x <..<= :: x -> x -> Range x
<..<= x
y = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty (x -> Bound x
forall x. x -> Bound x
Open x
x) (x -> Bound x
forall x. x -> Bound x
Closed x
y)
moreThan, atLeast, lessThan, atMost :: x -> Range x
moreThan :: x -> Range x
moreThan x
x = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty (x -> Bound x
forall x. x -> Bound x
Open x
x) Bound x
forall x. Bound x
Infinite
atLeast :: x -> Range x
atLeast x
x = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty (x -> Bound x
forall x. x -> Bound x
Closed x
x) Bound x
forall x. Bound x
Infinite
lessThan :: x -> Range x
lessThan x
x = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty Bound x
forall x. Bound x
Infinite (x -> Bound x
forall x. x -> Bound x
Open x
x)
atMost :: x -> Range x
atMost x
x = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty Bound x
forall x. Bound x
Infinite (x -> Bound x
forall x. x -> Bound x
Closed x
x)
singleton :: x -> Range x
singleton :: x -> Range x
singleton x
x = x
x x -> x -> Range x
forall x. x -> x -> Range x
<=..<= x
x
whole :: Range x
whole :: Range x
whole = Bound x -> Bound x -> Range x
forall x. Bound x -> Bound x -> Range x
NonEmpty Bound x
forall x. Bound x
Infinite Bound x
forall x. Bound x
Infinite
(.<@) :: Operator (null0 ty) (null1 ('PGrange ty)) ('Null 'PGbool)
.<@ :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
(.<@) = ByteString
-> Operator (null0 ty) (null1 ('PGrange ty)) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"<@"
(@>.) :: Operator (null0 ('PGrange ty)) (null1 ty) ('Null 'PGbool)
@>. :: Expression grp lat with db params from (null0 ('PGrange ty))
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from ('Null 'PGbool)
(@>.) = ByteString
-> Operator (null0 ('PGrange ty)) (null1 ty) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"@>"
(<<@) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
<<@ :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
(<<@) = ByteString
-> Operator
(null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"<<"
(@>>) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
@>> :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
(@>>) = ByteString
-> Operator
(null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
">>"
(&<) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
&< :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
(&<) = ByteString
-> Operator
(null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"&<"
(&>) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
&> :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
(&>) = ByteString
-> Operator
(null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"&>"
(-|-) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
-|- :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
(-|-) = ByteString
-> Operator
(null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"-|-"
(@+) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
@+ :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
(@+) = ByteString
-> Operator
(null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"+"
(@*) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
@* :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
(@*) = ByteString
-> Operator
(null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"*"
(@-) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
@- :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from (null ('PGrange ty))
(@-) = ByteString
-> Operator
(null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"-"
lowerBound :: null ('PGrange ty) --> 'Null ty
lowerBound :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null ty)
lowerBound = ByteString -> null ('PGrange ty) --> 'Null ty
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeFunction ByteString
"lower"
upperBound :: null ('PGrange ty) --> 'Null ty
upperBound :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null ty)
upperBound = ByteString -> null ('PGrange ty) --> 'Null ty
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeFunction ByteString
"upper"
isEmpty :: null ('PGrange ty) --> 'Null 'PGbool
isEmpty :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
isEmpty = ByteString -> null ('PGrange ty) --> 'Null 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeFunction ByteString
"isempty"
lowerInc :: null ('PGrange ty) --> 'Null 'PGbool
lowerInc :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
lowerInc = ByteString -> null ('PGrange ty) --> 'Null 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeFunction ByteString
"lower_inc"
lowerInf :: null ('PGrange ty) --> 'Null 'PGbool
lowerInf :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
lowerInf = ByteString -> null ('PGrange ty) --> 'Null 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeFunction ByteString
"lower_inf"
upperInc :: null ('PGrange ty) --> 'Null 'PGbool
upperInc :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
upperInc = ByteString -> null ('PGrange ty) --> 'Null 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeFunction ByteString
"upper_inc"
upperInf :: null ('PGrange ty) --> 'Null 'PGbool
upperInf :: Expression grp lat with db params from (null ('PGrange ty))
-> Expression grp lat with db params from ('Null 'PGbool)
upperInf = ByteString -> null ('PGrange ty) --> 'Null 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeFunction ByteString
"upper_inf"
rangeMerge ::
'[null ('PGrange ty), null ('PGrange ty)]
---> null ('PGrange ty)
rangeMerge :: NP
(Expression grp lat with db params from)
'[null ('PGrange ty), null ('PGrange ty)]
-> Expression grp lat with db params from (null ('PGrange ty))
rangeMerge = ByteString
-> '[null ('PGrange ty), null ('PGrange ty)]
---> null ('PGrange ty)
forall (xs :: [NullType]) (y :: NullType).
SListI xs =>
ByteString -> xs ---> y
unsafeFunctionN ByteString
"range_merge"