hasql-postgresql-types: Integration of "hasql" with "postgresql-types"

[ codecs, hasql, library, mit, postgresql ] [ Propose Tags ] [ Report a vulnerability ]

Provides automatic encoder and decoder generation for "hasql", supporting all PostgreSQL types defined in the "postgresql-types" package.

Motivation

The standard "hasql" codecs use common Haskell types like Text, DiffTime, UTCTime, etc. However these types do not always map precisely to PostgreSQL types. E.g., the PostgreSQL interval type carries information about months, years and microseconds, while the Haskell DiffTime type only represents a time difference in picoseconds. Such mismatches can lead to data loss or unexpected behavior. The "postgresql-types" library addresses such issues by providing precise Haskell representations for PostgreSQL types. This package integrates it with "hasql". It also provides a class-based polymorphic interface for defining "hasql" Value codecs.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.1.0.1
Dependencies base (>=4.11 && <5), hasql (>=1.10.1 && <1.11), postgresql-types-algebra (>=0.1 && <0.2), ptr-peeker (>=0.1.0.1 && <0.2), ptr-poker (>=0.1.3 && <0.2), tagged (>=0.8.9 && <0.9), text-builder (>=1.0.0.4 && <1.1) [details]
License MIT
Copyright (c) 2026, Nikita Volkov
Author Nikita Volkov <nikita.y.volkov@mail.ru>
Maintainer Nikita Volkov <nikita.y.volkov@mail.ru>
Uploaded by NikitaVolkov at 2026-01-23T09:06:53Z
Category PostgreSQL, Codecs, Hasql
Home page https://github.com/nikita-volkov/hasql-postgresql-types
Bug tracker https://github.com/nikita-volkov/hasql-postgresql-types/issues
Source repo head: git clone https://github.com/nikita-volkov/hasql-postgresql-types
Distributions
Downloads 3 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for hasql-postgresql-types-0.1.0.1

[back to package description]

hasql-postgresql-types

Hackage Continuous Haddock

Integration of "hasql" with "postgresql-types" via the IsScalar typeclass from "postgresql-types-algebra". Provides automatic encoder and decoder generation for precise PostgreSQL scalar types.

Motivation

The standard "hasql" codecs use common Haskell types like Text, DiffTime, UTCTime, etc. However these types do not always map precisely to PostgreSQL types. E.g., the PostgreSQL interval type carries information about months, years and microseconds, while the Haskell DiffTime type only represents a time difference in picoseconds. Such mismatches can lead to data loss or unexpected behavior. The "postgresql-types" library addresses such issues by providing precise Haskell representations for PostgreSQL types. This package integrates it with "hasql". It also provides a class-based polymorphic interface for defining "hasql" Value codecs.

Usage

import Hasql.PostgresqlTypes (encoder, decoder)
import qualified PostgresqlTypes as Pt
import qualified Hasql.Statement as Statement
import qualified Hasql.Encoders as Encoders
import qualified Hasql.Decoders as Decoders

myStatement :: Statement.Statement Pt.Timestamptz [Pt.Timestamptz]
myStatement = Statement.preparable sql enc dec
  where
    sql = "SELECT $1::timestamptz"
    enc = Encoders.param (Encoders.nonNullable encoder)
    dec = Decoders.rowList (Decoders.column (Decoders.nonNullable decoder))