-- 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.4 with the integer_datetimes setting -- off and on. @package postgresql-binary @version 0.7.5 -- | Models of supported data structures according to the serialisation -- format. module PostgreSQL.Binary.Data -- | A representation of a data serializable to the PostgreSQL array binary -- format. -- -- Consists of a vector of dimensions, a vector of encoded elements, a -- flag specifying, whether it contains any nulls, and an oid. type Array = (Vector ArrayDimension, Vector Content, Bool, OID) -- | A width and a lower bound. -- -- Currently the lower bound is only allowed to have a value of -- 1. type ArrayDimension = (Word32, Word32) -- | An encoded value. Nothing if it represents a NULL. type Content = Maybe ByteString -- | A Postgres OID of a type. type OID = Word32 -- | A representation of a composite Postgres data (Record or Row). type Composite = Vector (OID, Content) -- | HStore. type HStore = Vector (ByteString, Content) -- | The four components of UUID. type UUID = (Word32, Word32, Word32, Word32) -- | Representation of the PostgreSQL Numeric encoding. -- -- Consists of the following components: -- --
-- x :: Decoder [ [ Text ] ] -- x = -- array (arrayDimension replicateM (fmap catMaybes (arrayDimension replicateM (arrayValue text)))) --data ArrayDecoder a -- | Unlift an ArrayDecoder to a value Decoder. array :: ArrayDecoder a -> Decoder a -- | A function for parsing a dimension of an array. Provides support for -- multi-dimensional arrays. -- -- Accepts: -- --
-- hstoreAsList :: Decoder [ ( Text , Maybe Text ) ] -- hstoreAsList = -- hstore replicateM text text --hstore :: (forall m. Monad m => Int -> m (k, Maybe v) -> m r) -> Decoder k -> Decoder v -> Decoder r -- | Given a partial mapping from text to value, produces a decoder of that -- value. enum :: (Text -> Maybe a) -> Decoder a instance GHC.Base.Functor PostgreSQL.Binary.Decoder.ArrayDecoder instance GHC.Base.Monad PostgreSQL.Binary.Decoder.CompositeDecoder instance GHC.Base.Applicative PostgreSQL.Binary.Decoder.CompositeDecoder instance GHC.Base.Functor PostgreSQL.Binary.Decoder.CompositeDecoder module PostgreSQL.Binary.Encoder 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 :: Encoder Value -- | 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. 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 -- | A polymorphic in-place HSTORE encoder. -- -- Accepts: -- --
-- hashMapHStore :: Encoder (Data.HashMap.Strict.HashMap Text (Maybe Text)) -- hashMapHStore = -- hstore foldl' --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 -- | Given a function, which maps the value into the textual enum label -- from the DB side, produces an encoder of that value enum :: (a -> Text) -> Encoder a