postgresql-typed-0.5.1: PostgreSQL interface with compile-time SQL type checking, 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 #

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 # 

Methods

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

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

Eq a => Eq (Bound a) # 

Methods

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

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

newtype LowerBound a #

Constructors

Lower 

Fields

Instances

Functor LowerBound # 

Methods

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

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

Bounded a => Bounded (LowerBound a) #

The constraint is only necessary for maxBound, unfortunately

Eq a => Eq (LowerBound a) # 

Methods

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

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

Ord a => Ord (LowerBound a) #

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

newtype UpperBound a #

Constructors

Upper 

Fields

Instances

Functor UpperBound # 

Methods

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

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

Bounded a => Bounded (UpperBound a) #

The constraint is only necessary for minBound, unfortunately

Eq a => Eq (UpperBound a) # 

Methods

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

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

Ord a => Ord (UpperBound a) #

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

data Range a #

Constructors

Empty 
Range 

Fields

Instances

Functor Range # 

Methods

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

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

(PGRangeType t, PGColumn (PGSubType t) a) => PGColumn t (Range a) # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> Range a #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> Range a #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> Range a #

(PGRangeType t, PGParameter (PGSubType t) a) => PGParameter t (Range a) # 

Methods

pgEncode :: PGTypeID t -> Range a -> PGTextValue #

pgLiteral :: PGTypeID t -> Range a -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID t -> Range a -> PGValue #

Eq a => Eq (Range a) # 

Methods

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

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

Ord a => Ord (Range a) # 

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) # 

Methods

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

show :: Range a -> String #

showList :: [Range a] -> ShowS #

Ord a => Monoid (Range a) # 

Methods

mempty :: Range a #

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

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

bound :: Bound a -> Maybe a #

boundClosed :: Bound a -> Bool #

Unbounded endpoints are always open.

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

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

lowerBound :: Range a -> Bound a #

Empty ranges treated as Unbounded

upperBound :: Range a -> Bound a #

Empty ranges treated as Unbounded

lowerClosed :: Range a -> Bool #

Equivalent to boundClosed . lowerBound

upperClosed :: Range a -> Bool #

Equivalent to boundClosed . upperBound

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

full :: Range a #

isFull :: Range a -> Bool #

point :: a -> Range a #

Create a point range [x,x]

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

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

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

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

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

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

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

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

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

Contains range

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

Contains range

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

Contains element

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

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

class (PGType t, PGType (PGSubType t)) => PGRangeType t where #

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.

Associated Types

type PGSubType t :: Symbol #

Instances

PGRangeType "daterange" # 

Associated Types

type PGSubType ("daterange" :: Symbol) :: Symbol #

Methods

pgRangeElementType :: PGTypeID "daterange" -> PGTypeID (PGSubType "daterange") #

PGRangeType "int4range" # 

Associated Types

type PGSubType ("int4range" :: Symbol) :: Symbol #

Methods

pgRangeElementType :: PGTypeID "int4range" -> PGTypeID (PGSubType "int4range") #

PGRangeType "int8range" # 

Associated Types

type PGSubType ("int8range" :: Symbol) :: Symbol #

Methods

pgRangeElementType :: PGTypeID "int8range" -> PGTypeID (PGSubType "int8range") #

PGRangeType "numrange" # 

Associated Types

type PGSubType ("numrange" :: Symbol) :: Symbol #

Methods

pgRangeElementType :: PGTypeID "numrange" -> PGTypeID (PGSubType "numrange") #

PGRangeType "tsrange" # 

Associated Types

type PGSubType ("tsrange" :: Symbol) :: Symbol #

Methods

pgRangeElementType :: PGTypeID "tsrange" -> PGTypeID (PGSubType "tsrange") #

PGRangeType "tstzrange" # 

Associated Types

type PGSubType ("tstzrange" :: Symbol) :: Symbol #

Methods

pgRangeElementType :: PGTypeID "tstzrange" -> PGTypeID (PGSubType "tstzrange") #

Orphan instances

PGType "daterange" # 

Associated Types

type PGVal ("daterange" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "daterange" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "daterange" -> Bool #

PGType "int4range" # 

Associated Types

type PGVal ("int4range" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "int4range" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "int4range" -> Bool #

PGType "int8range" # 

Associated Types

type PGVal ("int8range" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "int8range" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "int8range" -> Bool #

PGType "numrange" # 

Associated Types

type PGVal ("numrange" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "numrange" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "numrange" -> Bool #

PGType "tsrange" # 

Associated Types

type PGVal ("tsrange" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "tsrange" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "tsrange" -> Bool #

PGType "tstzrange" # 

Associated Types

type PGVal ("tstzrange" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "tstzrange" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "tstzrange" -> Bool #