| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hasql.PostgresqlTypes
Contents
Description
This module provides a bridge between the types defined in the "postgresql-types" and the "hasql" library,
offering automatic encoder and decoder generation for types that implement the IsScalar constraint.
Usage Example
import Hasql.PostgresqlTypes ()
import qualified PostgresqlTypes as Pt
import qualified Hasql.Statement as Statement
import qualified Hasql.Encoders as Encoders
import qualified Hasql.Decoders as Decoders
import qualified Hasql.Mapping.IsScalar as IsScalar
myStatement :: Statement.Statement Pt.Timestamptz [Pt.Timestamptz]
myStatement = Statement.preparable sql enc dec
where
sql = "SELECT $1::timestamptz"
enc = Encoders.param (Encoders.nonNullable IsScalar.encoder)
dec = Decoders.rowList (Decoders.column (Decoders.nonNullable IsScalar.decoder))The encoder and decoder functions work with any type having an IsScalar instance,
automatically handling binary encoding/decoding and OID resolution.