Core type classes and algebra for PostgreSQL type mappings, extracted from "postgresql-types".
This package provides the fundamental abstractions for mapping Haskell types to PostgreSQL types:
- Type classes defining the algebra for PostgreSQL type mappings
- Error types for decoding failures
- Metadata support for type names, OIDs, and parameters
- No concrete implementations - just the algebra
The core type class for types that map to PostgreSQL values:
class IsScalar a where
-- Type metadata
typeName :: Tagged a Text
baseOid :: Tagged a (Maybe Word32)
arrayOid :: Tagged a (Maybe Word32)
typeParams :: Tagged a [Text]
typeSignature :: Tagged a Text
-- Binary format
binaryEncoder :: a -> Write.Write
binaryDecoder :: PtrPeeker.Variable (Either DecodingError a)
-- Textual format
textualEncoder :: a -> TextBuilder.TextBuilder
textualDecoder :: Attoparsec.Parser aThis class enables:
- Binary encoding/decoding using PostgreSQL's native binary format
- Textual encoding/decoding using PostgreSQL's text representation
- Type metadata including OIDs and type signatures for parameterized types
- Round-trip fidelity through all encoding combinations
Use this package to:
- Define custom PostgreSQL type mappings compatible with the "postgresql-types" ecosystem
- Create adapter libraries for different PostgreSQL client libraries
- Build generic tools that work with any
IsScalarinstance
This package is typically used indirectly through:
- "postgresql-types" - Concrete type implementations
- "hasql-postgresql-types" - "hasql" integration
- "postgresql-simple-postgresql-types" - "postgresql-simple" integration