hssqlppp-0.6.2: SQL parser and type checker

Safe HaskellSafe
LanguageHaskell2010

Database.HsSqlPpp.Types

Contents

Description

Contains the SQL data types, type errors, and a few supporting functions.

Synopsis

SQL types

data Type Source #

Standard types of things. This covers all the usual postgres types plus some extra ones added for use by the hssqlppp typechecker

Constructors

ScalarType Text

basic type of a scalar value. These are either built in types in postgres, or implemented in C or similar

DomainType Text

a domain type is used for a constraint on a table column which would used on multiple columns on a table or in multiple tables, using a domain type is a way of just writing the constraint once

EnumType Text

enum type, not really supported in hssqlppp yet

UnknownType

String literals in postgres have an unknown type. The effective type is determined using what seems to amount to some simple ad hoc rules based on the context of the string literal. Hssqlppp also treats ? placeholders and nulls the same way, so they have UnknownType, not sure how closely this matches postgres

ArrayType Type

postgres automatically creates an array type for every scalar type (plus some other types?) If there is no array type for a type in the catalog, then you can't work with arrays of that type

NamedCompositeType Text

refer to composite type in catalog by name. not sure if this needs to exist along with CompositeType

CompositeType [(Text, TypeExtra)]

refer to composite type by structure

TrefType [((Text, Text), TypeExtra)]

CompositeTypeExtra [(Text,TypeExtra)] | hack to support the environment for a tref

AnonymousCompositeType [Type]

the fields are anonymous as well as the type itself

Pseudo PseudoType

The pseudo type is used for types which only appear as argument or return types in function definitions and/or are used only in plpgsql and not regular sql. hssqlppp also follows this usage for the types used in hssqlppp which don't have an exact counterpart in postgres

Instances
Eq Type Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Methods

(==) :: Type -> Type -> Bool #

(/=) :: Type -> Type -> Bool #

Data Type Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type #

toConstr :: Type -> Constr #

dataTypeOf :: Type -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) #

gmapT :: (forall b. Data b => b -> b) -> Type -> Type #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r #

gmapQ :: (forall d. Data d => d -> u) -> Type -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Type -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Type -> m Type #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type #

Ord Type Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Methods

compare :: Type -> Type -> Ordering #

(<) :: Type -> Type -> Bool #

(<=) :: Type -> Type -> Bool #

(>) :: Type -> Type -> Bool #

(>=) :: Type -> Type -> Bool #

max :: Type -> Type -> Type #

min :: Type -> Type -> Type #

Show Type Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Methods

showsPrec :: Int -> Type -> ShowS #

show :: Type -> String #

showList :: [Type] -> ShowS #

data TypeExtra Source #

Quick fix to add precision and nullable information to the annotation types. This approach should be revisited, maybe this information should be in the Type type?

Constructors

TypeExtra 
Instances
Eq TypeExtra Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Data TypeExtra Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeExtra -> c TypeExtra #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeExtra #

toConstr :: TypeExtra -> Constr #

dataTypeOf :: TypeExtra -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TypeExtra) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeExtra) #

gmapT :: (forall b. Data b => b -> b) -> TypeExtra -> TypeExtra #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeExtra -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeExtra -> r #

gmapQ :: (forall d. Data d => d -> u) -> TypeExtra -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeExtra -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeExtra -> m TypeExtra #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeExtra -> m TypeExtra #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeExtra -> m TypeExtra #

Ord TypeExtra Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Show TypeExtra Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

data PseudoType Source #

Pseudo types: mainly used for the argument and return types of functions. The weird undocumented types are just used to represent functions with those types which are in the postgres default catalog

Constructors

SetOfType Type

setof is used for set returning functions

AnyElement

used to represent polymorphic functions, all the AnyElement parameters and the return type if AnyElement must be the same type for a given function call invocation.

AnyArray

like AnyElement, but the type must be an array type

AnyEnum

like AnyElement, but the type must be an enum type

AnyNonArray

like AnyElement, but the type must be a non array type

AnyRange 
Any

Any drops the restriction that all the Any types must be the same type

Record (Maybe Type)

record types are used in plpgsql for a sort of dynamic typing or rough polymorphism substitute. They can refer to values of named composite type, composite type or anonymous composite type, not sure if non composite types as well.

Void

presumably used for the types of OLD and NEW in a trigger function. Hssqlppp will probably use the Record type above for these. | TriggerRecord | Trigger | cstring - a C string | Cstring | represents the return type of a function which doesn't return anything. Not sure if it is used anywhere else

Instances
Eq PseudoType Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Data PseudoType Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PseudoType -> c PseudoType #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PseudoType #

toConstr :: PseudoType -> Constr #

dataTypeOf :: PseudoType -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PseudoType) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PseudoType) #

gmapT :: (forall b. Data b => b -> b) -> PseudoType -> PseudoType #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PseudoType -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PseudoType -> r #

gmapQ :: (forall d. Data d => d -> u) -> PseudoType -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> PseudoType -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PseudoType -> m PseudoType #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PseudoType -> m PseudoType #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PseudoType -> m PseudoType #

Ord PseudoType Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Show PseudoType Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Type errors

data TypeError Source #

Instances
Eq TypeError Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Data TypeError Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeError -> c TypeError #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeError #

toConstr :: TypeError -> Constr #

dataTypeOf :: TypeError -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TypeError) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeError) #

gmapT :: (forall b. Data b => b -> b) -> TypeError -> TypeError #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeError -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeError -> r #

gmapQ :: (forall d. Data d => d -> u) -> TypeError -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeError -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeError -> m TypeError #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeError -> m TypeError #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeError -> m TypeError #

Ord TypeError Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal

Show TypeError Source # 
Instance details

Defined in Database.HsSqlPpp.Internals.TypesInternal