-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Encoders and decoders for the PostgreSQL's binary format -- -- An API for dealing with PostgreSQL's binary data format. -- -- It can be used to implement performant bindings to Postgres. E.g., -- "hasql" is based on this library. -- -- It supports all Postgres versions starting from 8.3 and is tested -- against 8.3, 9.3 and 9.5 with the integer_datetimes setting -- off and on. @package postgresql-binary @version 0.12.3.1 -- | Reexports of all the data-types that this API supports. Useful for the -- reduction of dependencies in the "postgresql-binary" dependent -- libraries. module PostgreSQL.Binary.Data -- | A map from keys to values. A map cannot contain duplicate keys; each -- key can map to at most one value. data HashMap k v -- | A Map from keys k to values a. data Map k a -- | An arbitrary-precision number represented using scientific -- notation. -- -- This type describes the set of all Reals which have a -- finite decimal expansion. -- -- A scientific number with coefficient c and -- base10Exponent e corresponds to the Fractional -- number: fromInteger c * 10 ^^ e data Scientific -- | This is the simplest representation of UTC. It consists of the day -- number, and a time offset from midnight. Note that if a day has a leap -- second added to it, it will have 86401 seconds. data UTCTime -- | A simple day and time aggregate, where the day is of the specified -- parameter, and the time is a TimeOfDay. Conversion of this (as local -- civil time) to UTC depends on the time zone. Conversion of this (as -- local mean time) to UT1 depends on the longitude. data LocalTime -- | Time of day as represented in hour, minute and second (with -- picoseconds), typically used to express local time of day. data TimeOfDay -- | A TimeZone is a whole number of minutes offset from UTC, together with -- a name and a "just for summer" flag. data TimeZone -- | This is a length of time, as measured by a clock. Conversion functions -- will treat it as seconds. It has a precision of 10^-12 s. data DiffTime -- | The Modified Julian Day is a standard count of days, with zero being -- the day 1858-11-17. data Day -- | The UUID type. A Random instance is provided which produces -- version 4 UUIDs as specified in RFC 4122. The Storable and -- Binary instances are compatible with RFC 4122, storing the -- fields in network order as 16 bytes. data UUID -- | Boxed vectors, supporting efficient slicing. data Vector a -- | A JSON value represented as a Haskell value. data Value -- | IP address. type IP = IP46 IP4 IP6 -- | Network address: host address + network prefix length. data NetAddr a module PostgreSQL.Binary.Encoding type Encoding = Builder encodingBytes :: Encoding -> ByteString -- | Turn an array builder into final value. The first parameter is OID of -- the element type. array :: Word32 -> Array -> Encoding -- | A helper for encoding of arrays of single dimension from foldables. -- 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 vectors. 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 polymorphic HSTORE encoder. hStore_foldable :: Foldable foldable => foldable (Text, Maybe Text) -> Encoding -- | HSTORE encoder from HashMap. hStore_hashMap :: HashMap Text (Maybe Text) -> Encoding -- | HSTORE encoder from Map. 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 -- | Abstraction for encoding into multidimensional array. data Array encodingArray :: Encoding -> Array nullArray :: Array dimensionArray :: (forall b. (b -> a -> b) -> b -> c -> b) -> (a -> Array) -> c -> Array module PostgreSQL.Binary.Decoding valueParser :: Value a -> ByteString -> Either Text a type Value = BinaryParser int :: (Integral a, Bits a) => Value a float4 :: Value Float float8 :: Value Double bool :: Value Bool -- | BYTEA or any other type in its undecoded form. bytea_strict :: Value ByteString -- | BYTEA or any other type in its undecoded form. bytea_lazy :: Value LazyByteString -- | Any of the variable-length character types: BPCHAR, VARCHAR, NAME and -- TEXT. text_strict :: Value Text -- | Any of the variable-length character types: BPCHAR, VARCHAR, NAME and -- TEXT. text_lazy :: Value LazyText -- | A UTF-8-decoded char. char :: Value Char -- | Lifts a custom decoder implementation. fn :: (ByteString -> Either Text a) -> Value a numeric :: Value Scientific uuid :: Value UUID inet :: Value (NetAddr IP) json_ast :: Value Value -- | Given a function, which parses a plain UTF-8 JSON string encoded as a -- byte-array, produces a decoder. json_bytes :: (ByteString -> Either Text a) -> Value a jsonb_ast :: Value Value -- | Given a function, which parses a plain UTF-8 JSON string encoded as a -- byte-array, produces a decoder. -- -- For those wondering, yes, JSONB is encoded as plain JSON string in the -- binary format of Postgres. Sad, but true. jsonb_bytes :: (ByteString -> Either Text a) -> Value a -- | DATE values decoding. date :: Value Day -- | TIME values decoding for servers, which have -- integer_datetimes enabled. time_int :: Value TimeOfDay -- | TIME values decoding for servers, which don't have -- integer_datetimes enabled. time_float :: Value TimeOfDay -- | TIMETZ values decoding for servers, which have -- integer_datetimes enabled. timetz_int :: Value (TimeOfDay, TimeZone) -- | TIMETZ values decoding for servers, which don't have -- integer_datetimes enabled. timetz_float :: Value (TimeOfDay, TimeZone) -- | TIMESTAMP values decoding for servers, which have -- integer_datetimes enabled. timestamp_int :: Value LocalTime -- | TIMESTAMP values decoding for servers, which don't have -- integer_datetimes enabled. timestamp_float :: Value LocalTime -- | TIMESTAMP values decoding for servers, which have -- integer_datetimes enabled. timestamptz_int :: Value UTCTime -- | TIMESTAMP values decoding for servers, which don't have -- integer_datetimes enabled. timestamptz_float :: Value UTCTime -- | INTERVAL values decoding for servers, which don't have -- integer_datetimes enabled. interval_int :: Value DiffTime -- | INTERVAL values decoding for servers, which have -- integer_datetimes enabled. interval_float :: Value DiffTime -- | An efficient generic array decoder, which constructs the result value -- in place while parsing. -- -- Here's how you can use it to produce a specific array value decoder: -- --
--   x :: Value [ [ Text ] ]
--   x =
--     array (dimensionArray replicateM (fmap catMaybes (dimensionArray replicateM (nullableValueArray text))))
--   
data Array a -- | Unlift an Array to a value Value. array :: Array a -> Value a -- | Lift a value Value into Array for parsing of -- non-nullable leaf values. valueArray :: Value a -> Array a -- | Lift a value Value into Array for parsing of nullable -- leaf values. nullableValueArray :: Value a -> Array (Maybe a) -- | A function for parsing a dimension of an array. Provides support for -- multi-dimensional arrays. -- -- Accepts: -- -- dimensionArray :: (forall m. Monad m => Int -> m a -> m b) -> Array a -> Array b data Composite a -- | Unlift a Composite to a value Value. composite :: Composite a -> Value a -- | Lift a non-nullable value Value into Composite. valueComposite :: Value a -> Composite a -- | Lift a value Value into Composite. nullableValueComposite :: Value a -> Composite (Maybe a) -- | A function for generic in place parsing of an HStore value. -- -- Accepts: -- -- -- -- Here's how you can use it to produce a parser to list: -- --
--   hstoreAsList :: Value [ ( Text , Maybe Text ) ]
--   hstoreAsList =
--     hstore replicateM text text
--   
hstore :: (forall m. Monad m => Int -> m (k, Maybe v) -> m r) -> Value k -> Value v -> Value r -- | Given a partial mapping from text to value, produces a decoder of that -- value. enum :: (Text -> Maybe a) -> Value a -- | Given additional constraints when using an existing value decoder, -- produces a decoder of that value. refine :: (a -> Either Text b) -> Value a -> Value b instance GHC.Base.Functor PostgreSQL.Binary.Decoding.Array instance Control.Monad.Fail.MonadFail PostgreSQL.Binary.Decoding.Composite instance GHC.Base.Monad PostgreSQL.Binary.Decoding.Composite instance GHC.Base.Applicative PostgreSQL.Binary.Decoding.Composite instance GHC.Base.Functor PostgreSQL.Binary.Decoding.Composite