Movatterモバイル変換


[0]ホーム

URL:


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

Safe HaskellNone
LanguageHaskell2010

PostgreSQL.Binary.Decoder

Contents

Synopsis

Documentation

typeDecoder =BinaryParserSource

run ::BinaryParser a ->ByteString ->EitherText a

Apply a parser to bytes.

Primitive

int :: (Integral a,Bits a) =>Decoder aSource

float4 ::DecoderFloatSource

float8 ::DecoderDoubleSource

bool ::DecoderBoolSource

bytea_strict ::DecoderByteStringSource

BYTEA or any other type in its undecoded form.

bytea_lazy ::Decoder LazyByteStringSource

BYTEA or any other type in its undecoded form.

Textual

text_strict ::DecoderTextSource

Any of the variable-length character types: BPCHAR, VARCHAR, NAME and TEXT.

text_lazy ::Decoder LazyTextSource

Any of the variable-length character types: BPCHAR, VARCHAR, NAME and TEXT.

char ::DecoderCharSource

A UTF-8-decoded char.

Misc

fn :: (ByteString ->EitherText a) ->Decoder aSource

Lifts a custom decoder implementation.

numeric ::DecoderScientificSource

uuid ::DecoderUUIDSource

json_ast ::DecoderValueSource

json_bytes :: (ByteString ->EitherText a) ->Decoder aSource

Given a function, which parses a plain UTF-8 JSON string encoded as a byte-array, produces a decoder.

jsonb_ast ::DecoderValueSource

jsonb_bytes :: (ByteString ->EitherText a) ->Decoder aSource

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.

Time

date ::DecoderDaySource

DATE values decoding.

time_int ::DecoderTimeOfDaySource

TIME values decoding for servers, which haveinteger_datetimes enabled.

time_float ::DecoderTimeOfDaySource

TIME values decoding for servers, which don't haveinteger_datetimes enabled.

timetz_int ::Decoder (TimeOfDay,TimeZone)Source

TIMETZ values decoding for servers, which haveinteger_datetimes enabled.

timetz_float ::Decoder (TimeOfDay,TimeZone)Source

TIMETZ values decoding for servers, which don't haveinteger_datetimes enabled.

timestamp_int ::DecoderLocalTimeSource

TIMESTAMP values decoding for servers, which haveinteger_datetimes enabled.

timestamp_float ::DecoderLocalTimeSource

TIMESTAMP values decoding for servers, which don't haveinteger_datetimes enabled.

timestamptz_int ::DecoderUTCTimeSource

TIMESTAMP values decoding for servers, which haveinteger_datetimes enabled.

timestamptz_float ::DecoderUTCTimeSource

TIMESTAMP values decoding for servers, which don't haveinteger_datetimes enabled.

interval_int ::DecoderDiffTimeSource

INTERVAL values decoding for servers, which don't haveinteger_datetimes enabled.

interval_float ::DecoderDiffTimeSource

INTERVAL values decoding for servers, which haveinteger_datetimes enabled.

Exotic

Array

dataArrayDecoder aSource

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 :: Decoder [ [ Text ] ]x =  array (arrayDimension replicateM (fmap catMaybes (arrayDimension replicateM (arrayValue text))))

Instances

FunctorArrayDecoderSource 

array ::ArrayDecoder a ->Decoder aSource

Unlift anArrayDecoder to a valueDecoder.

arrayDimension :: (forall m.Monad m =>Int -> m a -> m b) ->ArrayDecoder a ->ArrayDecoder bSource

A function for parsing a dimension of an array. Provides support for multi-dimensional arrays.

Accepts:

arrayValue ::Decoder a ->ArrayDecoder (Maybe a)Source

Lift a valueDecoder intoArrayDecoder for parsing of nullable leaf values.

arrayNonNullValue ::Decoder a ->ArrayDecoder aSource

Lift a valueDecoder intoArrayDecoder for parsing of non-nullable leaf values.

Composite

dataCompositeDecoder aSource

Instances

MonadCompositeDecoderSource 
FunctorCompositeDecoderSource 
ApplicativeCompositeDecoderSource 

composite ::CompositeDecoder a ->Decoder aSource

Unlift aCompositeDecoder to a valueDecoder.

compositeValue ::Decoder a ->CompositeDecoder (Maybe a)Source

Lift a valueDecoder intoCompositeDecoder.

compositeNonNullValue ::Decoder a ->CompositeDecoder aSource

Lift a non-nullable valueDecoder intoCompositeDecoder.

HStore

hstore :: (forall m.Monad m =>Int -> m (k,Maybe v) -> m r) ->Decoder k ->Decoder v ->Decoder rSource

A function for generic in place parsing of an HStore value.

Accepts:

  • An implementation of thereplicateM function (Control.Monad.replicateM,Data.Vector.replicateM), which determines how to produce the final datastructure from the rows.
  • A decoder for keys.
  • A decoder for values.

Here's how you can use it to produce a parser to list:

hstoreAsList :: Decoder [ ( Text , Maybe Text ) ]hstoreAsList =  hstore replicateM text text

enum :: (Text ->Maybe a) ->Decoder aSource

Given a partial mapping from text to value, produces a decoder of that value.

Produced byHaddock version 2.16.1


[8]ページ先頭

©2009-2025 Movatter.jp