PostgreSQL.Binary.Encoding

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

Safe Haskell | None
Language | Haskell2010

PostgreSQL.Binary.Encoding

Contents

- Encoding
- Primitives
  - Time
  - JSON
- Array

Synopsis

- type Encoding = Builder
- encodingBytes :: Encoding -> ByteString
- array :: Word32 -> Array -> Encoding
- array_foldable :: Foldable foldable => Word32 -> (element -> Maybe Encoding) -> foldable element -> Encoding
- array_vector :: Word32 -> (element -> Encoding) -> Vector element -> Encoding
- nullableArray_vector :: Word32 -> (element -> Encoding) -> Vector (Maybe element) -> Encoding
- hStore_foldable :: Foldable foldable => foldable (Text, Maybe Text) -> Encoding
- hStore_hashMap :: HashMap Text (Maybe Text) -> Encoding
- hStore_map :: Map Text (Maybe Text) -> Encoding
- bool :: Bool -> Encoding
- int2_int16 :: Int16 -> Encoding
- int2_word16 :: Word16 -> Encoding
- int4_int32 :: Int32 -> Encoding
- int4_word32 :: Word32 -> Encoding
- int8_int64 :: Int64 -> Encoding
- int8_word64 :: Word64 -> Encoding
- float4 :: Float -> Encoding
- float8 :: Double -> Encoding
- numeric :: Scientific -> Encoding
- uuid :: UUID -> Encoding
- inet :: NetAddr IP -> Encoding
- char_utf8 :: Char -> Encoding
- text_strict :: Text -> Encoding
- text_lazy :: Text -> Encoding
- bytea_strict :: ByteString -> Encoding
- bytea_lazy :: ByteString -> Encoding
- date :: Day -> Encoding
- time_int :: TimeOfDay -> Encoding
- time_float :: TimeOfDay -> Encoding
- timetz_int :: (TimeOfDay, TimeZone) -> Encoding
- timetz_float :: (TimeOfDay, TimeZone) -> Encoding
- timestamp_int :: LocalTime -> Encoding
- timestamp_float :: LocalTime -> Encoding
- timestamptz_int :: UTCTime -> Encoding
- timestamptz_float :: UTCTime -> Encoding
- interval_int :: DiffTime -> Encoding
- interval_float :: DiffTime -> Encoding
- json_bytes :: ByteString -> Encoding
- json_ast :: Value -> Encoding
- jsonb_bytes :: ByteString -> Encoding
- jsonb_ast :: Value -> Encoding
- data Array
- encodingArray :: Encoding -> Array
- nullArray :: Array
- dimensionArray :: (forall b. (b -> a -> b) -> b -> c -> b) -> (a -> Array) -> c -> Array

# Encoding

type Encoding = Builder #

encodingBytes :: Encoding -> ByteString #

#

array :: Word32 -> Array -> Encoding #

Turn an array builder into final value. The first parameter is OID of the element type.

array_foldable :: Foldable foldable => Word32 -> (element -> Maybe Encoding) -> foldable element -> Encoding #

A helper for encoding of arrays of single dimension from foldables. The first parameter is OID of the element type.

array_vector :: Word32 -> (element -> Encoding) -> Vector element -> Encoding #

A helper for encoding of arrays of single dimension from vectors. The first parameter is OID of the element type.

nullableArray_vector :: Word32 -> (element -> Encoding) -> Vector (Maybe element) -> Encoding #

A helper for encoding of arrays of single dimension from vectors. The first parameter is OID of the element type.

hStore_foldable :: Foldable foldable => foldable (Text, Maybe Text) -> Encoding #

A polymorphic `HSTORE` encoder.

hStore_hashMap :: HashMap Text (Maybe Text) -> Encoding #

`HSTORE` encoder from HashMap.

hStore_map :: Map Text (Maybe Text) -> Encoding #

`HSTORE` encoder from Map.

# Primitives

bool :: Bool -> Encoding #

int2_int16 :: Int16 -> Encoding #

int2_word16 :: Word16 -> Encoding #

int4_int32 :: Int32 -> Encoding #

int4_word32 :: Word32 -> Encoding #

int8_int64 :: Int64 -> Encoding #

int8_word64 :: Word64 -> Encoding #

float4 :: Float -> Encoding #

float8 :: Double -> Encoding #

numeric :: Scientific -> Encoding #

uuid :: UUID -> Encoding #

inet :: NetAddr IP -> Encoding #

char_utf8 :: Char -> Encoding #

text_strict :: Text -> Encoding #

text_lazy :: Text -> Encoding #

bytea_strict :: ByteString -> Encoding #

bytea_lazy :: ByteString -> Encoding #

## Time

Some of the functions in this section are distinguished based on the `integer_datetimes` setting of the server.

date :: Day -> Encoding #

time_int :: TimeOfDay -> Encoding #

time_float :: TimeOfDay -> Encoding #

timetz_int :: (TimeOfDay, TimeZone) -> Encoding #

timetz_float :: (TimeOfDay, TimeZone) -> Encoding #

timestamp_int :: LocalTime -> Encoding #

timestamp_float :: LocalTime -> Encoding #

timestamptz_int :: UTCTime -> Encoding #

timestamptz_float :: UTCTime -> Encoding #

interval_int :: DiffTime -> Encoding #

interval_float :: DiffTime -> Encoding #

## JSON

json_bytes :: ByteString -> Encoding #

json_ast :: Value -> Encoding #

jsonb_bytes :: ByteString -> Encoding #

jsonb_ast :: Value -> Encoding #

# Array

data Array #

Abstraction for encoding into multidimensional array.

encodingArray :: Encoding -> Array #

nullArray :: Array #

dimensionArray :: (forall b. (b -> a -> b) -> b -> c -> b) -> (a -> Array) -> c -> Array #