postgresql-binary-0.9.1.1: Encoders and decoders for the PostgreSQL's binary format

Safe Haskell | None
Language | Haskell2010

PostgreSQL.Binary.Encoder

Contents

- Value encoder
- Array encoder
- Enum

Synopsis

- run :: Encoder a -> a -> ByteString
- type Encoder a = a -> Builder
- int2_int16 :: Encoder Int16
- int2_word16 :: Encoder Word16
- int4_int32 :: Encoder Int32
- int4_word32 :: Encoder Word32
- int8_int64 :: Encoder Int64
- int8_word64 :: Encoder Word64
- float4 :: Encoder Float
- float8 :: Encoder Double
- composite :: Encoder Composite
- bool :: Encoder Bool
- numeric :: Encoder Scientific
- uuid :: Encoder UUID
- json_ast :: Encoder Value
- json_bytes :: Encoder ByteString
- jsonb_ast :: Encoder Value
- jsonb_bytes :: Encoder ByteString
- char :: Encoder Char
- text_strict :: Encoder Text
- text_lazy :: Encoder Text
- bytea_strict :: Encoder ByteString
- bytea_lazy :: Encoder ByteString
- date :: Encoder Day
- time_int :: Encoder TimeOfDay
- time_float :: Encoder TimeOfDay
- timetz_int :: Encoder (TimeOfDay, TimeZone)
- timetz_float :: Encoder (TimeOfDay, TimeZone)
- timestamp_int :: Encoder LocalTime
- timestamp_float :: Encoder LocalTime
- timestamptz_int :: Encoder UTCTime
- timestamptz_float :: Encoder UTCTime
- interval_int :: Encoder DiffTime
- interval_float :: Encoder DiffTime
- hstore :: (forall a. (a -> (Text, Maybe Text) -> a) -> a -> b -> a) -> Encoder b
- hstoreRep :: Encoder HStore
- array :: Word32 -> ArrayEncoder a -> Encoder a
- data ArrayEncoder a
- arrayValue :: Encoder a -> ArrayEncoder a
- arrayNullableValue :: Encoder a -> ArrayEncoder (Maybe a)
- arrayDimension :: (forall a. (a -> b -> a) -> a -> c -> a) -> ArrayEncoder b -> ArrayEncoder c
- arrayRep :: Encoder Array
- enum :: (a -> Text) -> Encoder a

# Documentation

run :: Encoder a -> a -> ByteString #

# Value encoder

type Encoder a = a -> Builder #

int2_int16 :: Encoder Int16 #

int2_word16 :: Encoder Word16 #

int4_int32 :: Encoder Int32 #

int4_word32 :: Encoder Word32 #

int8_int64 :: Encoder Int64 #

int8_word64 :: Encoder Word64 #

float4 :: Encoder Float #

float8 :: Encoder Double #

composite :: Encoder Composite #

bool :: Encoder Bool #

numeric :: Encoder Scientific #

uuid :: Encoder UUID #

json_ast :: Encoder Value #

json_bytes :: Encoder ByteString #

jsonb_ast :: Encoder Value #

jsonb_bytes :: Encoder ByteString #

char :: Encoder Char #

A UTF-8-encoded char.

Note that since it's UTF-8-encoded not the "char" but the "text" OID should be used with it.

text_strict :: Encoder Text #

text_lazy :: Encoder Text #

bytea_strict :: Encoder ByteString #

bytea_lazy :: Encoder ByteString #

date :: Encoder Day #

time_int :: Encoder TimeOfDay #

time_float :: Encoder TimeOfDay #

timetz_int :: Encoder (TimeOfDay, TimeZone) #

timetz_float :: Encoder (TimeOfDay, TimeZone) #

timestamp_int :: Encoder LocalTime #

timestamp_float :: Encoder LocalTime #

timestamptz_int :: Encoder UTCTime #

timestamptz_float :: Encoder UTCTime #

interval_int :: Encoder DiffTime #

interval_float :: Encoder DiffTime #

hstore :: (forall a. (a -> (Text, Maybe Text) -> a) -> a -> b -> a) -> Encoder b #

A polymorphic in-place `HSTORE` encoder.

Accepts:

- An implementation of the `foldl` function (e.g., `Data.Foldable.`foldl'``), which determines the input value.

Here's how you can use it to produce a specific encoder:

    hashMapHStore :: Encoder (Data.HashMap.Strict.HashMap Text (Maybe Text))
    hashMapHStore =
      hstore foldl'

hstoreRep :: Encoder HStore #

array :: Word32 -> ArrayEncoder a -> Encoder a #

# Array encoder

data ArrayEncoder a #

arrayValue :: Encoder a -> ArrayEncoder a #

arrayNullableValue :: Encoder a -> ArrayEncoder (Maybe a) #

arrayDimension :: (forall a. (a -> b -> a) -> a -> c -> a) -> ArrayEncoder b -> ArrayEncoder c #

arrayRep :: Encoder Array #

# Enum

enum :: (a -> Text) -> Encoder a #

Given a function, which maps the value into the textual enum label from the DB side, produces an encoder of that value