| Safe Haskell | None |
|---|
Text.ProtocolBuffers.Basic
Contents
Description
- data Double
- data Float
- data Bool
- data Maybe a
- data Seq a
- newtype Utf8 = Utf8 ByteString
- data ByteString
- data Int32
- data Int64
- data Word32
- data Word64
- newtype WireTag = WireTag {
- getWireTag :: Word32
- newtype FieldId = FieldId {
- getFieldId :: Int32
- newtype WireType = WireType {}
- newtype FieldType = FieldType {
- getFieldType :: Int
- newtype EnumCode = EnumCode {
- getEnumCode :: Int32
- type WireSize = Int64
- class Default a => Mergeable a where
- mergeAppend :: a -> a -> a
- mergeConcat :: Foldable t => t a -> a
- class Default a where
- defaultValue :: a
- isValidUTF8 :: ByteString -> Maybe Int
- toUtf8 :: ByteString -> Either Int Utf8
- utf8 :: Utf8 -> ByteString
- uToString :: Utf8 -> String
- uFromString :: String -> Utf8
Basic types for protocol buffer fields in Haskell
data Double
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
Instances
data Float
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
Instances
| Enum Float | |
| Eq Float | |
| Floating Float | |
| Fractional Float | |
| Data Float | |
| Num Float | |
| Ord Float | |
| Read Float | |
| Real Float | |
| RealFloat Float | |
| RealFrac Float | |
| Show Float | |
| Typeable Float | |
| Generic Float | |
| Storable Float | |
| Default Float | |
| Mergeable Float | |
| Wire Float | |
| GPB Float | |
| IArray UArray Float | |
| MessageAPI msg (msg -> Float) Float | |
| MArray (STUArray s) Float (ST s) |
data Bool
data Maybe a
The Maybe type encapsulates an optional value. A value of type
either contains a value of type Maybe aa (represented as ),
or it is empty (represented as Just aNothing). Using Maybe is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as error.
The Maybe type is also a monad. It is a simple kind of error
monad, where all errors are represented by Nothing. A richer
error monad can be built using the Either type.
Instances
| Monad Maybe | |
| Functor Maybe | |
| Typeable1 Maybe | |
| MonadPlus Maybe | |
| Applicative Maybe | |
| Foldable Maybe | |
| Alternative Maybe | |
| ExtKey Maybe | |
| (Default msg, Default a) => MessageAPI msg (msg -> Maybe a) a | |
| Default v => MessageAPI msg (Key Maybe msg v) v | |
| Eq a => Eq (Maybe a) | |
| Data a => Data (Maybe a) | |
| Ord a => Ord (Maybe a) | |
| Read a => Read (Maybe a) | |
| Show a => Show (Maybe a) | |
| Generic (Maybe a) | |
| Monoid a => Monoid (Maybe a) | Lift a semigroup into |
| Default (Maybe a) | |
| Mergeable a => Mergeable (Maybe a) |
data Seq a
General-purpose finite sequences.
Instances
| Monad Seq | |
| Functor Seq | |
| Typeable1 Seq | |
| MonadPlus Seq | |
| Foldable Seq | |
| Traversable Seq | |
| ExtKey Seq | |
| MessageAPI msg (msg -> Seq a) (Seq a) | |
| Default v => MessageAPI msg (Key Seq msg v) (Seq v) | |
| Eq a => Eq (Seq a) | |
| Data a => Data (Seq a) | |
| Ord a => Ord (Seq a) | |
| Read a => Read (Seq a) | |
| Show a => Show (Seq a) | |
| Monoid (Seq a) | |
| Default (Seq a) | |
| Mergeable (Seq a) |
Utf8 is used to mark ByteString values that (should) contain
valud utf8 encoded strings. This type is used to represent
TYPE_STRING values.
Constructors
| Utf8 ByteString |
Instances
| Eq Utf8 | |
| Data Utf8 | |
| Ord Utf8 | |
| Read Utf8 | |
| Show Utf8 | |
| Typeable Utf8 | |
| Monoid Utf8 | |
| Default Utf8 | |
| Mergeable Utf8 | |
| Dotted Utf8 | |
| Wire Utf8 | |
| GPB Utf8 | |
| MessageAPI msg (msg -> Utf8) Utf8 | |
| Mangle (FIName Utf8) (PFName String) | |
| Mangle (FIName Utf8) (PMName String) | |
| Mangle (DIName Utf8) (PFName String) | |
| Mangle (DIName Utf8) (PMName String) | |
| Mangle (IName Utf8) (FName String) | |
| Mangle (IName Utf8) (MName String) |
data ByteString
A space-efficient representation of a Word8 vector, supporting many
efficient operations. A ByteString contains 8-bit characters only.
Instances of Eq, Ord, Read, Show, Data, Typeable
data Int32
32-bit signed integer type
Instances
| Bounded Int32 | |
| Enum Int32 | |
| Eq Int32 | |
| Integral Int32 | |
| Data Int32 | |
| Num Int32 | |
| Ord Int32 | |
| Read Int32 | |
| Real Int32 | |
| Show Int32 | |
| Ix Int32 | |
| Typeable Int32 | |
| Storable Int32 | |
| Bits Int32 | |
| Default Int32 | |
| Mergeable Int32 | |
| Wire Int32 | |
| GPB Int32 | |
| IArray UArray Int32 | |
| MessageAPI msg (msg -> Int32) Int32 | |
| MArray (STUArray s) Int32 (ST s) |
data Int64
64-bit signed integer type
Instances
| Bounded Int64 | |
| Enum Int64 | |
| Eq Int64 | |
| Integral Int64 | |
| Data Int64 | |
| Num Int64 | |
| Ord Int64 | |
| Read Int64 | |
| Real Int64 | |
| Show Int64 | |
| Ix Int64 | |
| Typeable Int64 | |
| Storable Int64 | |
| Bits Int64 | |
| Default Int64 | |
| Mergeable Int64 | |
| Wire Int64 | |
| GPB Int64 | |
| IArray UArray Int64 | |
| MessageAPI msg (msg -> Int64) Int64 | |
| MArray (STUArray s) Int64 (ST s) |
data Word32
32-bit unsigned integer type
Instances
| Bounded Word32 | |
| Enum Word32 | |
| Eq Word32 | |
| Integral Word32 | |
| Data Word32 | |
| Num Word32 | |
| Ord Word32 | |
| Read Word32 | |
| Real Word32 | |
| Show Word32 | |
| Ix Word32 | |
| Typeable Word32 | |
| Storable Word32 | |
| Bits Word32 | |
| Default Word32 | |
| Mergeable Word32 | |
| Wire Word32 | |
| GPB Word32 | |
| IArray UArray Word32 | |
| MessageAPI msg (msg -> Word32) Word32 | |
| MArray (STUArray s) Word32 (ST s) |
data Word64
64-bit unsigned integer type
Instances
| Bounded Word64 | |
| Enum Word64 | |
| Eq Word64 | |
| Integral Word64 | |
| Data Word64 | |
| Num Word64 | |
| Ord Word64 | |
| Read Word64 | |
| Real Word64 | |
| Show Word64 | |
| Ix Word64 | |
| Typeable Word64 | |
| Storable Word64 | |
| Bits Word64 | |
| Default Word64 | |
| Mergeable Word64 | |
| Wire Word64 | |
| GPB Word64 | |
| IArray UArray Word64 | |
| MessageAPI msg (msg -> Word64) Word64 | |
| MArray (STUArray s) Word64 (ST s) |
Haskell types that act in the place of DescritorProto values
WireTag is the 32 bit value with the upper 29 bits being the
FieldId and the lower 3 bits being the WireType
Constructors
| WireTag | |
Fields
| |
FieldId is the field number which can be in the range 1 to
2^29-1 but the value from 19000 to 19999 are forbidden (so sayeth
Google).
Constructors
| FieldId | |
Fields
| |
WireType is the 3 bit wire encoding value, and is currently in
the range 0 to 5, leaving 6 and 7 currently invalid.
- 0 Varint : int32, int64, uint32, uint64, sint32, sint64, bool, enum
- 1 64-bit : fixed64, sfixed64, double
- 2 Length-delimited : string, bytes, embedded messages
- 3 Start group : groups (deprecated)
- 4 End group : groups (deprecated)
- 5 32-bit : fixed32, sfixed32, float
Constructors
| WireType | |
Fields | |
FieldType is the integer associated with the
FieldDescriptorProto's Type. The allowed range is currently 1 to
18, as shown below (excerpt from descritor.proto)
// 0 is reserved for errors.
// Order is weird for historical reasons.
TYPE_DOUBLE = 1;
TYPE_FLOAT = 2;
TYPE_INT64 = 3; // Not ZigZag encoded. Negative numbers
// take 10 bytes. Use TYPE_SINT64 if negative
// values are likely.
TYPE_UINT64 = 4;
TYPE_INT32 = 5; // Not ZigZag encoded. Negative numbers
// take 10 bytes. Use TYPE_SINT32 if negative
// values are likely.
TYPE_FIXED64 = 6;
TYPE_FIXED32 = 7;
TYPE_BOOL = 8;
TYPE_STRING = 9;
TYPE_GROUP = 10; // Tag-delimited aggregate.
TYPE_MESSAGE = 11; // Length-delimited aggregate.
// New in version 2.
TYPE_BYTES = 12;
TYPE_UINT32 = 13;
TYPE_ENUM = 14;
TYPE_SFIXED32 = 15;
TYPE_SFIXED64 = 16;
TYPE_SINT32 = 17; // Uses ZigZag encoding.
TYPE_SINT64 = 18; // Uses ZigZag encoding.
Constructors
| FieldType | |
Fields
| |
EnumCode is the Int32 assoicated with a
EnumValueDescriptorProto and is in the range 0 to 2^31-1.
Constructors
| EnumCode | |
Fields
| |
WireSize is the Int64 size type associate with the lazy
bytestrings used in the Put and Get monads.
Some of the type classes implemented messages and fields
class Default a => Mergeable a whereSource
The Mergeable class is not a Monoid, mergeEmpty is not a
left or right unit like mempty. The default mergeAppend is to
take the second parameter and discard the first one. The
mergeConcat defaults to foldl associativity.
NOTE: mergeEmpty has been removed in protocol buffers version 2.
Use defaultValue instead. New strict fields would mean that required
fields in messages will be automatic errors with mergeEmpty.
Methods
mergeAppend :: a -> a -> aSource
mergeAppend is the right-biased merge of two values. A
message (or group) is merged recursively. Required field are
always taken from the second message. Optional field values are
taken from the most defined message or the second message if
both are set. Repeated fields have the sequences concatenated.
Note that strings and bytes are NOT concatenated.
mergeConcat :: Foldable t => t a -> aSource
mergeConcat is F.foldl mergeAppend defaultValue and this
default definition is not overridden in any of the code except
for the (Seq a) instance.
The Default class has the default-default values of types. See
http://code.google.com/apis/protocolbuffers/docs/proto.html#optional
and also note that Enum types have a defaultValue that is the
first one in the .proto file (there is always at least one
value). Instances of this for messages hold any default value
defined in the .proto file. defaultValue is where the
MessageAPI function getVal looks when an optional field is not
set.
Methods
defaultValue :: aSource
The defaultValue is never undefined or an error to evalute.
This makes it much more useful compared to mergeEmpty. In a
default message all Optional field values are set to Nothing
and Repeated field values are empty.
isValidUTF8 :: ByteString -> Maybe IntSource
utf8 :: Utf8 -> ByteStringSource
uFromString :: String -> Utf8Source