preql-0.5: safe PostgreSQL queries using Quasiquoters
Safe HaskellNone
LanguageHaskell2010

Preql.Wire.Internal

Description

The types in this module have invariants which cannot be checked if their constructors are in scope. Preql.Wire exports the type names only.

Synopsis

Documentation

newtype Query (n :: Nat) Source #

The IsString instance does no validation; the limited instances discourage directly manipulating strings, with the high risk of SQL injection. A Query is tagged with a Nat representing the width of its return type.

Constructors

Query ByteString 

Instances

Instances details
Show (Query n) Source # 
Instance details

Defined in Preql.Wire.Internal

Methods

showsPrec :: Int -> Query n -> ShowS #

show :: Query n -> String #

showList :: [Query n] -> ShowS #

IsString (Query n) Source # 
Instance details

Defined in Preql.Wire.Internal

Methods

fromString :: String -> Query n #

data RowDecoder (n :: Nat) a Source #

RowDecoder is Functor but not Monad so that we can index the type by the number of columns that it consumes. We also know & verify all of the OIDs before we read any of the field data sent by Postgres, which would admit an Applicative instance but not Monad

Constructors

RowDecoder (Vector n PgType) (InternalDecoder a) 

Instances

Instances details
Functor (RowDecoder n) Source # 
Instance details

Defined in Preql.Wire.Internal

Methods

fmap :: (a -> b) -> RowDecoder n a -> RowDecoder n b #

(<$) :: a -> RowDecoder n b -> RowDecoder n a #

pureDecoder :: a -> RowDecoder 0 a Source #

Analogous to pure, pureDecoder a returns the value a without consuming any input from Postgres.

applyDecoder :: RowDecoder m (a -> b) -> RowDecoder n a -> RowDecoder (m + n) b Source #

Analogous to <*>, pureDecoder Constructor applyDecoder a applyDecoder b supplies two arguments to Constructor, from the RowDecoder a and b.

type InternalDecoder = ReaderT (IORef DecoderState) IO Source #

Internal because we need IO for the libpq FFI, but we promise not to do any IO besides decoding. We don't even make network calls to Postgres in InternalDecoder

data DecoderState Source #

Constructors

DecoderState 

Fields

Instances

Instances details
Eq DecoderState Source # 
Instance details

Defined in Preql.Wire.Internal

Show DecoderState Source # 
Instance details

Defined in Preql.Wire.Internal

decodeRow :: IORef DecoderState -> RowDecoder n a -> Result -> IO a Source #

Can throw FieldError