postgresql-typed-0.4.5: A PostgreSQL library with compile-time SQL type inference and optional HDBC backend

Copyright2015 Dylan Simon
Safe HaskellNone
LanguageHaskell98

Database.PostgreSQL.Typed.Range

Contents

Description

Representaion of PostgreSQL's range type. There are a number of existing range data types, but PostgreSQL's is rather particular. This tries to provide a one-to-one mapping.

Synopsis

Documentation

data Bound a Source #

A end-point for a range, which may be nothing (infinity, NULL in PostgreSQL), open (inclusive), or closed (exclusive)

Constructors

Unbounded

Equivalent to Bounded False ±Infinity

Bounded 

Fields

Instances

Functor Bound Source # 

Methods

fmap :: (a -> b) -> Bound a -> Bound b #

(<$) :: a -> Bound b -> Bound a #

Eq a => Eq (Bound a) Source # 

Methods

(==) :: Bound a -> Bound a -> Bool #

(/=) :: Bound a -> Bound a -> Bool #

newtype LowerBound a Source #

Constructors

Lower 

Fields

Instances

Functor LowerBound Source # 

Methods

fmap :: (a -> b) -> LowerBound a -> LowerBound b #

(<$) :: a -> LowerBound b -> LowerBound a #

Bounded a => Bounded (LowerBound a) Source #

The constraint is only necessary for maxBound, unfortunately

Eq a => Eq (LowerBound a) Source # 

Methods

(==) :: LowerBound a -> LowerBound a -> Bool #

(/=) :: LowerBound a -> LowerBound a -> Bool #

Ord a => Ord (LowerBound a) Source #

Takes into account open vs. closed (but does not understand equivalent discrete bounds)

newtype UpperBound a Source #

Constructors

Upper 

Fields

Instances

Functor UpperBound Source # 

Methods

fmap :: (a -> b) -> UpperBound a -> UpperBound b #

(<$) :: a -> UpperBound b -> UpperBound a #

Bounded a => Bounded (UpperBound a) Source #

The constraint is only necessary for minBound, unfortunately

Eq a => Eq (UpperBound a) Source # 

Methods

(==) :: UpperBound a -> UpperBound a -> Bool #

(/=) :: UpperBound a -> UpperBound a -> Bool #

Ord a => Ord (UpperBound a) Source #

Takes into account open vs. closed (but does not understand equivalent discrete bounds)

data Range a Source #

Constructors

Empty 
Range 

Fields

Instances

Functor Range Source # 

Methods

fmap :: (a -> b) -> Range a -> Range b #

(<$) :: a -> Range b -> Range a #

(PGRangeType tr t, PGColumn t a) => PGColumn tr (Range a) Source # 

Methods

pgDecode :: PGTypeName tr -> PGTextValue -> Range a Source #

pgDecodeBinary :: PGTypeEnv -> PGTypeName tr -> PGBinaryValue -> Range a Source #

pgDecodeValue :: PGTypeEnv -> PGTypeName tr -> PGValue -> Range a Source #

(PGRangeType tr t, PGParameter t a) => PGParameter tr (Range a) Source # 
Eq a => Eq (Range a) Source # 

Methods

(==) :: Range a -> Range a -> Bool #

(/=) :: Range a -> Range a -> Bool #

Ord a => Ord (Range a) Source # 

Methods

compare :: Range a -> Range a -> Ordering #

(<) :: Range a -> Range a -> Bool #

(<=) :: Range a -> Range a -> Bool #

(>) :: Range a -> Range a -> Bool #

(>=) :: Range a -> Range a -> Bool #

max :: Range a -> Range a -> Range a #

min :: Range a -> Range a -> Range a #

Show a => Show (Range a) Source # 

Methods

showsPrec :: Int -> Range a -> ShowS #

show :: Range a -> String #

showList :: [Range a] -> ShowS #

Ord a => Monoid (Range a) Source # 

Methods

mempty :: Range a #

mappend :: Range a -> Range a -> Range a #

mconcat :: [Range a] -> Range a #

boundClosed :: Bound a -> Bool Source #

Unbounded endpoints are always open.

makeBound :: Bool -> Maybe a -> Bound a Source #

Construct from parts: makeBound (boundClosed b) (bound b) == b

lowerBound :: Range a -> Bound a Source #

Empty ranges treated as Unbounded

upperBound :: Range a -> Bound a Source #

Empty ranges treated as Unbounded

lowerClosed :: Range a -> Bool Source #

Equivalent to boundClosed . lowerBound

upperClosed :: Range a -> Bool Source #

Equivalent to boundClosed . upperBound

isEmpty :: Ord a => Range a -> Bool Source #

point :: a -> Range a Source #

Create a point range [x,x]

getPoint :: Eq a => Range a -> Maybe a Source #

Extract a point: getPoint (point x) == Just x

range :: Ord a => Bound a -> Bound a -> Range a Source #

normal :: Ord a => Maybe a -> Maybe a -> Range a Source #

bounded :: Ord a => a -> a -> Range a Source #

normalize :: Ord a => Range a -> Range a Source #

normalize' :: (Ord a, Enum a) => Range a -> Range a Source #

normalize for discrete (non-continuous) range types, using the Enum instance

(@>) :: Ord a => Range a -> Range a -> Bool Source #

Contains range

(<@) :: Ord a => Range a -> Range a -> Bool Source #

Contains range

(@>.) :: Ord a => Range a -> a -> Bool Source #

Contains element

overlaps :: Ord a => Range a -> Range a -> Bool Source #

intersect :: Ord a => Range a -> Range a -> Range a Source #

class (PGType tr, PGType t) => PGRangeType tr t | tr -> t where Source #

Class indicating that the first PostgreSQL type is a range of the second. This implies PGParameter and PGColumn instances that will work for any type.

Instances

PGRangeType "daterange" "date" Source # 

Methods

pgRangeElementType :: PGTypeName "daterange" -> PGTypeName "date" Source #

PGRangeType "int4range" "integer" Source # 

Methods

pgRangeElementType :: PGTypeName "int4range" -> PGTypeName "integer" Source #

PGRangeType "int8range" "bigint" Source # 

Methods

pgRangeElementType :: PGTypeName "int8range" -> PGTypeName "bigint" Source #

PGRangeType "numrange" "numeric" Source # 

Methods

pgRangeElementType :: PGTypeName "numrange" -> PGTypeName "numeric" Source #

PGRangeType "tsrange" "timestamp without time zone" Source # 

Methods

pgRangeElementType :: PGTypeName "tsrange" -> PGTypeName "timestamp without time zone" Source #

PGRangeType "tstzrange" "timestamp with time zone" Source # 

Methods

pgRangeElementType :: PGTypeName "tstzrange" -> PGTypeName "timestamp with time zone" Source #

Orphan instances

PGType "daterange" Source # 

Methods

pgTypeName :: PGTypeName "daterange" -> String Source #

pgBinaryColumn :: PGTypeEnv -> PGTypeName "daterange" -> Bool Source #

PGType "int4range" Source # 

Methods

pgTypeName :: PGTypeName "int4range" -> String Source #

pgBinaryColumn :: PGTypeEnv -> PGTypeName "int4range" -> Bool Source #

PGType "int8range" Source # 

Methods

pgTypeName :: PGTypeName "int8range" -> String Source #

pgBinaryColumn :: PGTypeEnv -> PGTypeName "int8range" -> Bool Source #

PGType "numrange" Source # 

Methods

pgTypeName :: PGTypeName "numrange" -> String Source #

pgBinaryColumn :: PGTypeEnv -> PGTypeName "numrange" -> Bool Source #

PGType "tsrange" Source # 
PGType "tstzrange" Source # 

Methods

pgTypeName :: PGTypeName "tstzrange" -> String Source #

pgBinaryColumn :: PGTypeEnv -> PGTypeName "tstzrange" -> Bool Source #