-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parse Google Protocol Buffer specifications -- -- Parse proto files and generate Haskell code. @package protocol-buffers @version 2.4.2 -- | By Chris Kuklewicz, drawing heavily from binary and binary-strict, but -- all the bugs are my own. -- -- This file is under the usual BSD3 licence, copyright 2008. -- -- Modified the monad to be strict for version 2.0.0 -- -- This started out as an improvement to -- Data.Binary.Strict.IncrementalGet with slightly better -- internals. The simplified Get, runGet, Result -- trio with the Data.Binary.Strict.Class.BinaryParser instance -- are an _untested_ upgrade from IncrementalGet. Especially untested are -- the strictness properties. -- -- Get usefully implements Applicative and Monad, MonadError, -- Alternative and MonadPlus. Unhandled errors are reported along with -- the number of bytes successfully consumed. Effects of suspend -- and putAvailable are visible after failthrowErrormzero. -- -- Each time the parser reaches the end of the input it will return a -- Partial wrapped continuation which requests a (Maybe Lazy.ByteString). -- Passing (Just bs) will append bs to the input so far and continue -- processing. If you pass Nothing to the continuation then you are -- declaring that there will never be more input and that the parser -- should never again return a partial contination; it should return -- failure or finished. -- -- suspendUntilComplete repeatedly uses a partial continuation to -- ask for more input until Nothing is passed and then it proceeds -- with parsing. -- -- The getAvailable command returns the lazy byte string the -- parser has remaining before calling suspend. The -- putAvailable replaces this input and is a bit fancy: it also -- replaces the input at the current offset for all the potential -- catchError/mplus handlers. This change is _not_ reverted by -- failthrowErrormzero. -- -- The three lookAhead and lookAheadM and lookAheadE -- functions are very similar to the ones in binary's Data.Binary.Get. -- -- Add specialized high-bit-run module Text.ProtocolBuffers.Get data Get a -- | runGet is the simple executor runGet :: Get a -> ByteString -> Result a -- | runGetAll is the simple executor, and will not ask for any -- continuation because this lazy bytestring is all the input runGetAll :: Get a -> ByteString -> Result a data Result a Failed :: {-# UNPACK #-} !Int64 -> String -> Result a Finished :: !ByteString -> {-# UNPACK #-} !Int64 -> a -> Result a Partial :: (Maybe ByteString -> Result a) -> Result a -- | check that there are at least n bytes available in the input. -- This will suspend if there is to little data. ensureBytes :: Int64 -> Get () getStorable :: forall a. (Storable a) => Get a -- | Pull n bytes from the input, as a lazy ByteString. This will -- suspend if there is too little data. getLazyByteString :: Int64 -> Get ByteString -- | Keep calling suspend until Nothing is passed to the -- Partial continuation. This ensures all the data has been loaded -- into the state of the parser. suspendUntilComplete :: Get () -- | Get the input currently available to the parser. getAvailable :: Get ByteString -- | putAvailable replaces the bytestream past the current # of read -- bytes. This will also affect pending MonadError handler and MonadPlus -- branches. I think all pending branches have to have fewer bytesRead -- than the current one. If this is wrong then an error will be thrown. -- -- WARNING : putAvailable is still untested. putAvailable :: ByteString -> Get () -- | lookAhead runs the todo action and then rewinds only -- the BinaryParser state. Any new input from suspend or changes -- from putAvailable are kept. Changes to the user state -- (MonadState) are kept. The MonadWriter output is retained. -- -- If an error is thrown then the entire monad state is reset to last -- catchError as usual. lookAhead :: Get a -> Get a -- | lookAheadM runs the todo action. If the action returns -- Nothing then the BinaryParser state is rewound (as in -- lookAhead). If the action return Just then the -- BinaryParser is not rewound, and lookAheadM acts as an identity. -- -- If an error is thrown then the entire monad state is reset to last -- catchError as usual. lookAheadM :: Get (Maybe a) -> Get (Maybe a) -- | lookAheadE runs the todo action. If the action returns -- Left then the BinaryParser state is rewound (as in -- lookAhead). If the action return Right then the -- BinaryParser is not rewound, and lookAheadE acts as an identity. -- -- If an error is thrown then the entire monad state is reset to last -- catchError as usual. lookAheadE :: Get (Either a b) -> Get (Either a b) -- | Discard the next m bytes skip :: Int64 -> Get () -- | Return the number of bytesRead so far. Initially 0, never -- negative. bytesRead :: Get Int64 -- | Return True if the number of bytes remaining is 0. Any futher -- attempts to read an empty parser will call suspend which might -- result in more input to consume. -- -- Compare with isReallyEmpty isEmpty :: Get Bool -- | Return True if the input is exhausted and will never be added to. -- Returns False if there is input left to consume. -- -- Compare with isEmpty isReallyEmpty :: Get Bool -- | Return the number of bytes remaining before the current input -- runs out and suspend might be called. remaining :: Get Int64 -- | get the longest prefix of the input where all the bytes satisfy the -- predicate. spanOf :: (Word8 -> Bool) -> Get (ByteString) -- | get the longest prefix of the input where the high bit is set as well -- as following byte. This made getVarInt slower. highBitRun :: Get Int64 getWord8 :: Get Word8 -- | Pull n bytes from the input, as a strict ByteString. This -- will suspend if there is too little data. If the result spans multiple -- lazy chunks then the result occupies a freshly allocated strict -- bytestring, otherwise it fits in a single chunk and refers to the same -- immutable memory block as the whole chunk. getByteString :: Int -> Get ByteString getWord16be :: Get Word16 getWord32be :: Get Word32 getWord64be :: Get Word64 getWord16le :: Get Word16 getWord32le :: Get Word32 getWord64le :: Get Word64 getWordhost :: Get Word getWord16host :: Get Word16 getWord32host :: Get Word32 getWord64host :: Get Word64 decode7 :: forall s. (Integral s, Bits s) => Get s decode7size :: Get Int64 decode7unrolled :: forall s. (Num s, Integral s, Bits s) => Get s instance GHC.Show.Show Text.ProtocolBuffers.Get.S instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Get.Result a) instance GHC.Show.Show (Text.ProtocolBuffers.Get.FrameStack b) instance Text.ProtocolBuffers.Get.MonadSuspend Text.ProtocolBuffers.Get.Get instance GHC.Base.Functor Text.ProtocolBuffers.Get.Get instance GHC.Base.Monad Text.ProtocolBuffers.Get.Get instance Control.Monad.Error.Class.MonadError GHC.Base.String Text.ProtocolBuffers.Get.Get instance GHC.Base.MonadPlus Text.ProtocolBuffers.Get.Get instance GHC.Base.Applicative Text.ProtocolBuffers.Get.Get instance GHC.Base.Alternative Text.ProtocolBuffers.Get.Get -- | Text.ProtocolBuffers.Basic defines or re-exports most of the -- basic field types; Maybe,Bool, Double, and -- Float come from the Prelude instead. This module also defines -- the Mergeable and Default classes. The Wire -- class is not defined here to avoid orphans. module Text.ProtocolBuffers.Basic -- | 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. data Double :: * -- | 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. data Float :: * data Bool :: * -- | The Maybe type encapsulates an optional value. A value of type -- Maybe a either contains a value of type a -- (represented as Just a), or it is empty (represented -- as Nothing). 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. data Maybe a :: * -> * -- | General-purpose finite sequences. data Seq a :: * -> * -- | Utf8 is used to mark ByteString values that (should) -- contain valid utf8 encoded strings. This type is used to represent -- TYPE_STRING values. newtype Utf8 Utf8 :: ByteString -> Utf8 -- | A space-efficient representation of a Word8 vector, supporting -- many efficient operations. -- -- A lazy ByteString contains 8-bit bytes, or by using the -- operations from Data.ByteString.Lazy.Char8 it can be -- interpreted as containing 8-bit characters. data ByteString :: * -- | 32-bit signed integer type data Int32 :: * -- | 64-bit signed integer type data Int64 :: * -- | 32-bit unsigned integer type data Word32 :: * -- | 64-bit unsigned integer type data Word64 :: * -- | WireTag is the 32 bit value with the upper 29 bits being the -- FieldId and the lower 3 bits being the WireType newtype WireTag WireTag :: Word32 -> WireTag [getWireTag] :: WireTag -> Word32 -- | 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). newtype FieldId FieldId :: Int32 -> FieldId [getFieldId] :: FieldId -> Int32 -- | WireType is the 3 bit wire encoding value, and is currently in -- the range 0 to 5, leaving 6 and 7 currently invalid. -- -- newtype WireType WireType :: Word32 -> WireType [getWireType] :: WireType -> Word32 -- | 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.
--   
newtype FieldType FieldType :: Int -> FieldType [getFieldType] :: FieldType -> Int -- | EnumCode is the Int32 assoicated with a -- EnumValueDescriptorProto and is in the range 0 to 2^31-1. newtype EnumCode EnumCode :: Int32 -> EnumCode [getEnumCode] :: EnumCode -> Int32 -- | WireSize is the Int64 size type associated with the lazy -- bytestrings used in the Put and Get monads. type WireSize = Int64 -- | 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. class Default a => Mergeable a where mergeAppend _a b = b mergeConcat = foldl mergeAppend defaultValue -- | 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. mergeAppend :: Mergeable a => a -> a -> a -- | mergeConcat is F.foldl mergeAppend defaultValue and -- this default definition is not overridden in any of the code except -- for the (Seq a) instance. mergeConcat :: (Mergeable a, Foldable t) => t a -> a -- | 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. class Default a -- | 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. defaultValue :: Default a => a isValidUTF8 :: ByteString -> Maybe Int toUtf8 :: ByteString -> Either Int Utf8 utf8 :: Utf8 -> ByteString uToString :: Utf8 -> String uFromString :: String -> Utf8 instance Data.Data.Data Text.ProtocolBuffers.Basic.EnumCode instance GHC.Num.Num Text.ProtocolBuffers.Basic.EnumCode instance GHC.Show.Show Text.ProtocolBuffers.Basic.EnumCode instance GHC.Read.Read Text.ProtocolBuffers.Basic.EnumCode instance GHC.Classes.Ord Text.ProtocolBuffers.Basic.EnumCode instance GHC.Classes.Eq Text.ProtocolBuffers.Basic.EnumCode instance Data.Data.Data Text.ProtocolBuffers.Basic.FieldType instance GHC.Num.Num Text.ProtocolBuffers.Basic.FieldType instance GHC.Show.Show Text.ProtocolBuffers.Basic.FieldType instance GHC.Read.Read Text.ProtocolBuffers.Basic.FieldType instance GHC.Enum.Enum Text.ProtocolBuffers.Basic.FieldType instance GHC.Classes.Ord Text.ProtocolBuffers.Basic.FieldType instance GHC.Classes.Eq Text.ProtocolBuffers.Basic.FieldType instance Data.Data.Data Text.ProtocolBuffers.Basic.WireType instance GHC.Num.Num Text.ProtocolBuffers.Basic.WireType instance GHC.Show.Show Text.ProtocolBuffers.Basic.WireType instance GHC.Read.Read Text.ProtocolBuffers.Basic.WireType instance GHC.Enum.Enum Text.ProtocolBuffers.Basic.WireType instance GHC.Classes.Ord Text.ProtocolBuffers.Basic.WireType instance GHC.Classes.Eq Text.ProtocolBuffers.Basic.WireType instance GHC.Arr.Ix Text.ProtocolBuffers.Basic.FieldId instance Data.Data.Data Text.ProtocolBuffers.Basic.FieldId instance GHC.Num.Num Text.ProtocolBuffers.Basic.FieldId instance GHC.Show.Show Text.ProtocolBuffers.Basic.FieldId instance GHC.Read.Read Text.ProtocolBuffers.Basic.FieldId instance GHC.Enum.Enum Text.ProtocolBuffers.Basic.FieldId instance GHC.Classes.Ord Text.ProtocolBuffers.Basic.FieldId instance GHC.Classes.Eq Text.ProtocolBuffers.Basic.FieldId instance Data.Data.Data Text.ProtocolBuffers.Basic.WireTag instance GHC.Enum.Bounded Text.ProtocolBuffers.Basic.WireTag instance Data.Bits.Bits Text.ProtocolBuffers.Basic.WireTag instance GHC.Num.Num Text.ProtocolBuffers.Basic.WireTag instance GHC.Show.Show Text.ProtocolBuffers.Basic.WireTag instance GHC.Read.Read Text.ProtocolBuffers.Basic.WireTag instance GHC.Enum.Enum Text.ProtocolBuffers.Basic.WireTag instance GHC.Classes.Ord Text.ProtocolBuffers.Basic.WireTag instance GHC.Classes.Eq Text.ProtocolBuffers.Basic.WireTag instance GHC.Classes.Ord Text.ProtocolBuffers.Basic.Utf8 instance GHC.Classes.Eq Text.ProtocolBuffers.Basic.Utf8 instance Data.Data.Data Text.ProtocolBuffers.Basic.Utf8 instance GHC.Read.Read Text.ProtocolBuffers.Basic.Utf8 instance GHC.Show.Show Text.ProtocolBuffers.Basic.Utf8 instance GHC.Base.Monoid Text.ProtocolBuffers.Basic.Utf8 instance GHC.Enum.Bounded Text.ProtocolBuffers.Basic.FieldId instance GHC.Enum.Bounded Text.ProtocolBuffers.Basic.WireType instance GHC.Enum.Bounded Text.ProtocolBuffers.Basic.FieldType instance GHC.Enum.Bounded Text.ProtocolBuffers.Basic.EnumCode instance Text.ProtocolBuffers.Basic.Mergeable a => Text.ProtocolBuffers.Basic.Mergeable (GHC.Base.Maybe a) instance Text.ProtocolBuffers.Basic.Mergeable (Data.Sequence.Seq a) instance Text.ProtocolBuffers.Basic.Mergeable GHC.Types.Bool instance Text.ProtocolBuffers.Basic.Mergeable Text.ProtocolBuffers.Basic.Utf8 instance Text.ProtocolBuffers.Basic.Mergeable Data.ByteString.Lazy.Internal.ByteString instance Text.ProtocolBuffers.Basic.Mergeable GHC.Types.Double instance Text.ProtocolBuffers.Basic.Mergeable GHC.Types.Float instance Text.ProtocolBuffers.Basic.Mergeable GHC.Int.Int32 instance Text.ProtocolBuffers.Basic.Mergeable GHC.Int.Int64 instance Text.ProtocolBuffers.Basic.Mergeable GHC.Word.Word32 instance Text.ProtocolBuffers.Basic.Mergeable GHC.Word.Word64 instance Text.ProtocolBuffers.Basic.Default GHC.Word.Word64 instance Text.ProtocolBuffers.Basic.Default GHC.Word.Word32 instance Text.ProtocolBuffers.Basic.Default GHC.Int.Int64 instance Text.ProtocolBuffers.Basic.Default GHC.Int.Int32 instance Text.ProtocolBuffers.Basic.Default GHC.Types.Float instance Text.ProtocolBuffers.Basic.Default GHC.Types.Double instance Text.ProtocolBuffers.Basic.Default GHC.Types.Bool instance Text.ProtocolBuffers.Basic.Default (GHC.Base.Maybe a) instance Text.ProtocolBuffers.Basic.Default (Data.Sequence.Seq a) instance Text.ProtocolBuffers.Basic.Default Data.ByteString.Lazy.Internal.ByteString instance Text.ProtocolBuffers.Basic.Default Text.ProtocolBuffers.Basic.Utf8 -- | This modules colelct utility routines related to the different -- incarnations of identifiers in the code. The basic identifier is -- always ASCII, but because of the self generated DescriptorProto data -- structures it is stored in Utf8 tagged lazy bytestrings. -- -- An identifier is a non-empty ASCII string made of -- [a-zA-Z0-9_] where the first character is never in [0-9]. -- -- A field is a mangled identifer that is a valid Haskell name -- that begins with lower case, and which may have a single quote at the -- end if needed to avoid a reserved word. These may also start with '_', -- though just a "_" is mangled to "_'". -- -- A 'module' is a mangled identifier that is a valid Haskell name that -- begins with upper case. These never have a single quote. A leading '_' -- is replaced with a leading U'_ to make a valid identifier. module Text.ProtocolBuffers.Identifiers unull :: Utf8 -> Bool toString :: Utf8 -> String fromString :: String -> Utf8 -- | Contains one identifier name newtype IName a IName :: a -> IName a [iName] :: IName a -> a -- | . separated identifier which may or may start with a dot. There -- are never two or more .s in a row. There is always at least one -- identifier. newtype DIName a DIName :: a -> DIName a [diName] :: DIName a -> a -- | Fully qualified identifier: repeated (. then identifier) newtype FIName a FIName :: a -> FIName a [fiName] :: FIName a -> a -- | Contains one module name, non-empty newtype MName a MName :: a -> MName a [mName] :: MName a -> a -- | Full Haskell module name: MNames separated by ., ending with a -- module newtype FMName a FMName :: a -> FMName a [fmName] :: FMName a -> a -- | Parsed Haskell name ending with MName. Good contructor to use. data PMName a PMName :: [MName a] -> (MName a) -> PMName a -- | Contains one field name, non-empty newtype FName a FName :: a -> FName a [fName] :: FName a -> a -- | Full Haskell field name: MNames separated by ., ending with a -- field newtype FFName a FFName :: a -> FFName a [ffName] :: FFName a -> a -- | Parsed Haskell name ending with FName. Good constructor to use. data PFName a PFName :: [MName a] -> (FName a) -> PFName a -- | This is used to abstract over Utf8 and String. The important entry -- point is validDI. class (Monoid a) => Dotted a uncons :: Dotted a => a -> Maybe (Char, a) cons :: Dotted a => Char -> a -> a dot :: Dotted a => a -> a -> a validI :: Dotted a => a -> Maybe (IName a) -- | validDI ensures the DIName is validDI :: Dotted a => a -> Maybe (DIName a) -- | split returns a list of non-empty a with all . -- characters removed split :: Dotted a => a -> [a] -- | The mangle transformation has instances for several -- combiantions of input and output. These allow one to construct the -- Haskell types of MNameFMNamePMName and FNameFFNamePFName -- out of the protobuf types INameDINameFIName. Currently, all the -- Haskell instances are for the String base type. class Mangle a b mangle :: Mangle a b => a -> b joinPM :: Dotted a => PMName a -> FMName a joinPF :: Dotted a => PFName a -> FFName a -- | difi examines the DIName and prepend a . if -- absent, promoting it to a FIName. difi :: Dotted a => DIName a -> FIName a -- | Typed split splitDI :: Dotted a => DIName a -> [IName a] -- | Typed split splitFI :: Dotted a => FIName a -> [IName a] -- | Typed split splitFM :: Dotted a => FMName a -> [MName a] -- | Right (True,_) means the input is a FIName. Right (False,_) means the -- input is a DIName (without leading .) -- -- This creates useful error messages for the user. checkDIString :: String -> Either String (Bool, [IName String]) -- | Right (True,_) means the input is a FIName. Right (False,_) means the -- input is a DIName (without leading .) -- -- This creates useful error messages for the user. checkDIUtf8 :: Utf8 -> Either String (Bool, [IName Utf8]) promoteDI :: Dotted a => IName a -> DIName a promoteFI :: Dotted a => IName a -> FIName a promoteFM :: Dotted a => MName a -> FMName a promoteFF :: Dotted a => FName a -> FFName a dotFM :: Dotted a => FMName a -> FMName a -> FMName a dotFF :: Dotted a => FMName a -> FFName a -> FFName a fqAppend :: Dotted a => FIName a -> [IName a] -> FIName a instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.PFName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.PFName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.PFName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.PFName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.PFName a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.PMName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.PMName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.PMName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.PMName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.PMName a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.FFName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.FFName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.FFName a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.FMName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.FMName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.FMName a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.FIName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.FIName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.FIName a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.DIName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.DIName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.DIName a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.FName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.FName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.FName a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.MName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.MName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.MName a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.ProtocolBuffers.Identifiers.IName a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.ProtocolBuffers.Identifiers.IName a) instance Data.Data.Data a => Data.Data.Data (Text.ProtocolBuffers.Identifiers.IName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.IName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.MName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.FName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.DIName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.FIName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.FFName a) instance GHC.Read.Read a => GHC.Read.Read (Text.ProtocolBuffers.Identifiers.FMName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.IName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.MName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.FName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.DIName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.FIName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.FMName a) instance GHC.Show.Show a => GHC.Show.Show (Text.ProtocolBuffers.Identifiers.FFName a) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.IName GHC.Base.String) (Text.ProtocolBuffers.Identifiers.MName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.IName Text.ProtocolBuffers.Basic.Utf8) (Text.ProtocolBuffers.Identifiers.MName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.FName GHC.Base.String) (Text.ProtocolBuffers.Identifiers.MName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.IName GHC.Base.String) (Text.ProtocolBuffers.Identifiers.FName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.IName Text.ProtocolBuffers.Basic.Utf8) (Text.ProtocolBuffers.Identifiers.FName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.MName GHC.Base.String) (Text.ProtocolBuffers.Identifiers.FName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.DIName Text.ProtocolBuffers.Basic.Utf8) (Text.ProtocolBuffers.Identifiers.PMName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.FIName Text.ProtocolBuffers.Basic.Utf8) (Text.ProtocolBuffers.Identifiers.PMName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.DIName Text.ProtocolBuffers.Basic.Utf8) (Text.ProtocolBuffers.Identifiers.PFName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Mangle (Text.ProtocolBuffers.Identifiers.FIName Text.ProtocolBuffers.Basic.Utf8) (Text.ProtocolBuffers.Identifiers.PFName GHC.Base.String) instance Text.ProtocolBuffers.Identifiers.Dotted Text.ProtocolBuffers.Basic.Utf8 instance Text.ProtocolBuffers.Identifiers.Dotted GHC.Base.String -- | A strong feature of the protocol-buffers package is that it does not -- contain any structures defined by descriptor.proto! This prevents me -- hitting any annoying circular dependencies. The structures defined -- here are included in each module created by hprotoc. They are -- optimized for use in code generation. -- -- These values can be inspected at runtime by the user's code, but I -- have yet to write much documentation. Luckily the record field names -- are somewhat descriptive. -- -- The other reflection is using the fileDescriptorProto which -- is put into the top level module created by hprotoc. module Text.ProtocolBuffers.Reflections -- | This is fully qualified name data type for code generation. The -- haskellPrefix was possibly specified on the hprotoc -- command line. The parentModule is a combination of the module -- prefix from the '.proto' file and any nested levels of definition. -- -- The name components are likely to have been mangled to ensure the -- baseName started with an uppercase letter, in ['A'..'Z'] -- . data ProtoName ProtoName :: FIName Utf8 -> [MName String] -> [MName String] -> MName String -> ProtoName -- | fully qualified name using "package" prefix (no mangling) [protobufName] :: ProtoName -> FIName Utf8 -- | Haskell specific prefix to module hierarchy (e.g. Text.Foo) [haskellPrefix] :: ProtoName -> [MName String] -- | .proto specified namespace (like Com.Google.Bar) [parentModule] :: ProtoName -> [MName String] [baseName] :: ProtoName -> MName String data ProtoFName ProtoFName :: FIName Utf8 -> [MName String] -> [MName String] -> FName String -> String -> ProtoFName -- | fully qualified name using "package" prefix (no mangling) [protobufName'] :: ProtoFName -> FIName Utf8 -- | Haskell specific prefix to module hierarchy (e.g. Text.Foo) [haskellPrefix'] :: ProtoFName -> [MName String] -- | .proto specified namespace (like Com.Google.Bar) [parentModule'] :: ProtoFName -> [MName String] [baseName'] :: ProtoFName -> FName String [baseNamePrefix'] :: ProtoFName -> String data ProtoInfo ProtoInfo :: ProtoName -> [FilePath] -> FilePath -> Seq KeyInfo -> [DescriptorInfo] -> [EnumInfo] -> [OneofInfo] -> Map ProtoName (Seq FieldInfo) -> ProtoInfo -- | blank protobufName, maybe blank haskellPrefix and/or parentModule [protoMod] :: ProtoInfo -> ProtoName -- | path to haskell module [protoFilePath] :: ProtoInfo -> [FilePath] -- | filename without path of .proto file [protoSource] :: ProtoInfo -> FilePath -- | top level keys [extensionKeys] :: ProtoInfo -> Seq KeyInfo -- | all messages and groups [messages] :: ProtoInfo -> [DescriptorInfo] -- | all enums [enums] :: ProtoInfo -> [EnumInfo] [oneofs] :: ProtoInfo -> [OneofInfo] [knownKeyMap] :: ProtoInfo -> Map ProtoName (Seq FieldInfo) data DescriptorInfo DescriptorInfo :: ProtoName -> [FilePath] -> Bool -> Seq FieldInfo -> Seq OneofInfo -> Seq KeyInfo -> [(FieldId, FieldId)] -> Seq FieldInfo -> Bool -> Bool -> Bool -> DescriptorInfo [descName] :: DescriptorInfo -> ProtoName [descFilePath] :: DescriptorInfo -> [FilePath] [isGroup] :: DescriptorInfo -> Bool [fields] :: DescriptorInfo -> Seq FieldInfo [descOneofs] :: DescriptorInfo -> Seq OneofInfo [keys] :: DescriptorInfo -> Seq KeyInfo [extRanges] :: DescriptorInfo -> [(FieldId, FieldId)] [knownKeys] :: DescriptorInfo -> Seq FieldInfo [storeUnknown] :: DescriptorInfo -> Bool [lazyFields] :: DescriptorInfo -> Bool [makeLenses] :: DescriptorInfo -> Bool data FieldInfo FieldInfo :: ProtoFName -> FieldId -> WireTag -> Maybe (WireTag, WireTag) -> WireSize -> Bool -> Bool -> Bool -> Bool -> FieldType -> Maybe ProtoName -> Maybe ByteString -> Maybe HsDefault -> FieldInfo [fieldName] :: FieldInfo -> ProtoFName [fieldNumber] :: FieldInfo -> FieldId -- | Used for writing and reading if packedTag is Nothing [wireTag] :: FieldInfo -> WireTag -- | used for reading when Just {} instead of wireTag [packedTag] :: FieldInfo -> Maybe (WireTag, WireTag) -- | Bytes required in the Varint formatted wireTag [wireTagLength] :: FieldInfo -> WireSize [isPacked] :: FieldInfo -> Bool [isRequired] :: FieldInfo -> Bool -- | True if repeated is the field type [canRepeat] :: FieldInfo -> Bool -- | True if packed would be valid for this field type [mightPack] :: FieldInfo -> Bool -- | fromEnum of Text.DescriptorProtos.FieldDescriptorProto.Type [typeCode] :: FieldInfo -> FieldType -- | Set for Messages,Groups,and Enums [typeName] :: FieldInfo -> Maybe ProtoName -- | crappy, but not escaped, thing [hsRawDefault] :: FieldInfo -> Maybe ByteString -- | nice parsed thing [hsDefault] :: FieldInfo -> Maybe HsDefault type KeyInfo = (ProtoName, FieldInfo) -- | HsDefault stores the parsed default from the proto file in a -- form that will make a nice literal in the -- Language.Haskell.Exts.Syntax code generation by -- hprotoc. -- -- Note that Utf8 labeled byte sequences have been stripped to just -- ByteString here as this is sufficient for code generation. -- -- On 25 August 2010 20:12, George van den Driessche -- georgevdd@google.com sent Chris Kuklewicz a patch to -- MakeReflections.parseDefEnum to ensure that HsDef'Enum holds the -- mangled form of the name. data HsDefault HsDef'Bool :: Bool -> HsDefault HsDef'ByteString :: ByteString -> HsDefault HsDef'RealFloat :: SomeRealFloat -> HsDefault HsDef'Integer :: Integer -> HsDefault HsDef'Enum :: String -> HsDefault -- | SomeRealFloat projects Double/Float to Rational or a special -- IEEE type. This is needed to track protobuf-2.3.0 which allows nan and -- inf and -inf default values. data SomeRealFloat SRF'Rational :: Rational -> SomeRealFloat SRF'nan :: SomeRealFloat SRF'ninf :: SomeRealFloat SRF'inf :: SomeRealFloat data EnumInfo EnumInfo :: ProtoName -> [FilePath] -> [(EnumCode, String)] -> EnumInfo [enumName] :: EnumInfo -> ProtoName [enumFilePath] :: EnumInfo -> [FilePath] -- | The String is the Haskell name to write into the generated source -- files [enumValues] :: EnumInfo -> [(EnumCode, String)] type EnumInfoApp e = [(EnumCode, String, e)] class ReflectDescriptor m where getMessageInfo x = cached where cached = makeMessageInfo (reflectDescriptorInfo (undefined `asTypeOf` x)) makeMessageInfo :: DescriptorInfo -> GetMessageInfo makeMessageInfo di = GetMessageInfo {requiredTags = fromDistinctAscList . sort $ [wireTag f | f <- toList (fields di), isRequired f], allowedTags = fromDistinctAscList . sort $ [wireTag f | f <- toList (fields di)] ++ [wireTag f | f <- toList (knownKeys di)]} -- | This is obtained via read on the stored show output of -- the DescriptorInfo in the module file. It is used in getting -- messages from the wire. -- -- Must not inspect argument getMessageInfo :: ReflectDescriptor m => m -> GetMessageInfo reflectDescriptorInfo :: ReflectDescriptor m => m -> DescriptorInfo class ReflectEnum e where parentOfEnum _ = Nothing reflectEnum :: ReflectEnum e => EnumInfoApp e reflectEnumInfo :: ReflectEnum e => e -> EnumInfo parentOfEnum :: ReflectEnum e => e -> Maybe DescriptorInfo -- | GetMessageInfo is used in getting messages from the wire. It -- supplies the Set of precomposed wire tags that must be found in -- the message as well as a Set of all allowed tags (including -- known extension fields and all required wire tags). -- -- Extension fields not in the allowedTags set are still loaded, but only -- as ByteString blobs that will have to interpreted later. data GetMessageInfo GetMessageInfo :: Set WireTag -> Set WireTag -> GetMessageInfo [requiredTags] :: GetMessageInfo -> Set WireTag [allowedTags] :: GetMessageInfo -> Set WireTag data OneofInfo OneofInfo :: ProtoName -> ProtoFName -> [FilePath] -> Seq (ProtoName, FieldInfo) -> Bool -> OneofInfo [oneofName] :: OneofInfo -> ProtoName [oneofFName] :: OneofInfo -> ProtoFName [oneofFilePath] :: OneofInfo -> [FilePath] [oneofFields] :: OneofInfo -> Seq (ProtoName, FieldInfo) [oneofMakeLenses] :: OneofInfo -> Bool -- | makePNF is used by the generated code to create a ProtoName -- with less newtype noise. makePNF :: ByteString -> [String] -> [String] -> String -> ProtoName toRF :: (RealFloat a, Fractional a) => SomeRealFloat -> a fromRF :: (RealFloat a, Fractional a) => a -> SomeRealFloat instance Data.Data.Data Text.ProtocolBuffers.Reflections.ProtoInfo instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.ProtoInfo instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.ProtoInfo instance GHC.Read.Read Text.ProtocolBuffers.Reflections.ProtoInfo instance GHC.Show.Show Text.ProtocolBuffers.Reflections.ProtoInfo instance Data.Data.Data Text.ProtocolBuffers.Reflections.EnumInfo instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.EnumInfo instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.EnumInfo instance GHC.Read.Read Text.ProtocolBuffers.Reflections.EnumInfo instance GHC.Show.Show Text.ProtocolBuffers.Reflections.EnumInfo instance Data.Data.Data Text.ProtocolBuffers.Reflections.DescriptorInfo instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.DescriptorInfo instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.DescriptorInfo instance GHC.Read.Read Text.ProtocolBuffers.Reflections.DescriptorInfo instance GHC.Show.Show Text.ProtocolBuffers.Reflections.DescriptorInfo instance Data.Data.Data Text.ProtocolBuffers.Reflections.OneofInfo instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.OneofInfo instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.OneofInfo instance GHC.Read.Read Text.ProtocolBuffers.Reflections.OneofInfo instance GHC.Show.Show Text.ProtocolBuffers.Reflections.OneofInfo instance Data.Data.Data Text.ProtocolBuffers.Reflections.FieldInfo instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.FieldInfo instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.FieldInfo instance GHC.Read.Read Text.ProtocolBuffers.Reflections.FieldInfo instance GHC.Show.Show Text.ProtocolBuffers.Reflections.FieldInfo instance Data.Data.Data Text.ProtocolBuffers.Reflections.HsDefault instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.HsDefault instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.HsDefault instance GHC.Read.Read Text.ProtocolBuffers.Reflections.HsDefault instance GHC.Show.Show Text.ProtocolBuffers.Reflections.HsDefault instance Data.Data.Data Text.ProtocolBuffers.Reflections.SomeRealFloat instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.SomeRealFloat instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.SomeRealFloat instance GHC.Read.Read Text.ProtocolBuffers.Reflections.SomeRealFloat instance GHC.Show.Show Text.ProtocolBuffers.Reflections.SomeRealFloat instance Data.Data.Data Text.ProtocolBuffers.Reflections.GetMessageInfo instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.GetMessageInfo instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.GetMessageInfo instance GHC.Read.Read Text.ProtocolBuffers.Reflections.GetMessageInfo instance GHC.Show.Show Text.ProtocolBuffers.Reflections.GetMessageInfo instance Data.Data.Data Text.ProtocolBuffers.Reflections.ProtoFName instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.ProtoFName instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.ProtoFName instance GHC.Read.Read Text.ProtocolBuffers.Reflections.ProtoFName instance GHC.Show.Show Text.ProtocolBuffers.Reflections.ProtoFName instance Data.Data.Data Text.ProtocolBuffers.Reflections.ProtoName instance GHC.Classes.Ord Text.ProtocolBuffers.Reflections.ProtoName instance GHC.Classes.Eq Text.ProtocolBuffers.Reflections.ProtoName instance GHC.Read.Read Text.ProtocolBuffers.Reflections.ProtoName instance GHC.Show.Show Text.ProtocolBuffers.Reflections.ProtoName module Text.ProtocolBuffers.TextMessage -- | This writes message as text-format protobuf to String messagePutText :: TextMsg a => a -> String -- | This reads message as text-format protobuf from any Parsec-compatible -- source. Input must be completely consumed. messageGetText :: (TextMsg a, Stream s Identity Char) => s -> Either String a -- | Printable and readable messages class TextMsg a textPut :: TextMsg a => a -> Output textGet :: (TextMsg a, Stream s Identity Char) => Parsec s () a -- | Printable and readable field types class TextType a tellT :: TextType a => String -> a -> Output getT :: (TextType a, Stream s Identity Char) => String -> Parsec s () a tellShow :: Show a => String -> a -> Output tellSubMessage :: TextMsg a => String -> a -> Output getRead :: forall a s. (Read a, Stream s Identity Char) => String -> Parsec s () a getSubMessage :: (Stream s Identity Char, TextMsg a) => String -> Parsec s () a instance Text.ProtocolBuffers.TextMessage.TextType GHC.Int.Int32 instance Text.ProtocolBuffers.TextMessage.TextType GHC.Int.Int64 instance Text.ProtocolBuffers.TextMessage.TextType GHC.Word.Word32 instance Text.ProtocolBuffers.TextMessage.TextType GHC.Word.Word64 instance Text.ProtocolBuffers.TextMessage.TextType GHC.Types.Bool instance Text.ProtocolBuffers.TextMessage.TextType GHC.Types.Double instance Text.ProtocolBuffers.TextMessage.TextType GHC.Types.Float instance Text.ProtocolBuffers.TextMessage.TextType Text.ProtocolBuffers.Basic.Utf8 instance Text.ProtocolBuffers.TextMessage.TextType Data.ByteString.Lazy.Internal.ByteString instance Text.ProtocolBuffers.TextMessage.TextType a => Text.ProtocolBuffers.TextMessage.TextType (GHC.Base.Maybe a) instance Text.ProtocolBuffers.TextMessage.TextType a => Text.ProtocolBuffers.TextMessage.TextType (Data.Sequence.Seq a) -- | Here are the serialization and deserialization functions. -- -- This module cooperates with the generated code to implement the Wire -- instances. The encoding is mostly documented at -- http://code.google.com/apis/protocolbuffers/docs/encoding.html. -- -- The user API functions are grouped into sections and documented. The -- rest are for internal use. The main functions are messageGet -- and messagePut (and messageSize). There are then several -- 'message*' variants which allow for finer control and for making -- delimited messages. module Text.ProtocolBuffers.WireMessage -- | This computes the size of the message's fields with tags on the wire -- with no initial tag or length (in bytes). This is also the length of -- the message as placed between group start and stop tags. messageSize :: (ReflectDescriptor msg, Wire msg) => msg -> WireSize -- | This is runPut applied to messagePutM. It result in a -- ByteString with a length of messageSize bytes. messagePut :: (ReflectDescriptor msg, Wire msg) => msg -> ByteString -- | This consumes the ByteString to decode a message. It assumes -- the ByteString is merely a sequence of the tagged fields of the -- message, and consumes until a group stop tag is detected or the entire -- input is consumed. Any ByteString past the end of the stop tag -- is returned as well. -- -- This is runGetOnLazy applied to messageGetM. messageGet :: (ReflectDescriptor msg, Wire msg) => ByteString -> Either String (msg, ByteString) -- | This writes just the message's fields with tags to the wire. This -- Put monad can be composed and eventually executed with -- runPut. -- -- This is actually wirePut 10 msg messagePutM :: (ReflectDescriptor msg, Wire msg) => msg -> Put -- | This reads the tagged message fields until the stop tag or the end of -- input is reached. -- -- This is actually wireGet 10 msg messageGetM :: (ReflectDescriptor msg, Wire msg) => Get msg -- | This computes the size of the message fields as in messageSize -- and add the length of the encoded size to the total. Thus this is the -- the length of the message including the encoded length header, but -- without any leading tag. messageWithLengthSize :: (ReflectDescriptor msg, Wire msg) => msg -> WireSize -- | This is runPut applied to messageWithLengthPutM. It -- results in a ByteString with a length of -- messageWithLengthSize bytes. messageWithLengthPut :: (ReflectDescriptor msg, Wire msg) => msg -> ByteString -- | This runGetOnLazy applied to messageWithLengthGetM. -- -- This first reads the encoded length of the message and will then -- succeed when it has consumed precisely this many additional bytes. The -- ByteString after this point will be returned. messageWithLengthGet :: (ReflectDescriptor msg, Wire msg) => ByteString -> Either String (msg, ByteString) -- | This writes the encoded length of the message's fields and then the -- message's fields with tags to the wire. This Put monad can be -- composed and eventually executed with runPut. -- -- This is actually wirePut 11 msg messageWithLengthPutM :: (ReflectDescriptor msg, Wire msg) => msg -> Put -- | This reads the encoded message length and then the message. -- -- This is actually wireGet 11 msg messageWithLengthGetM :: (ReflectDescriptor msg, Wire msg) => Get msg -- | This computes the size of the messageWithLengthSize and then -- adds the length an initial tag with the given FieldId. messageAsFieldSize :: (ReflectDescriptor msg, Wire msg) => FieldId -> msg -> WireSize -- | This writes an encoded wire tag with the given FieldId and then -- the encoded length of the message's fields and then the message's -- fields with tags to the wire. This Put monad can be composed -- and eventually executed with runPut. messageAsFieldPutM :: (ReflectDescriptor msg, Wire msg) => FieldId -> msg -> Put -- | This reads a wire tag (must be of type '2') to get the FieldId. -- Then the encoded message length is read, followed by the message -- itself. Both the FieldId and the message are returned. -- -- This allows for incremental reading and processing. messageAsFieldGetM :: (ReflectDescriptor msg, Wire msg) => Get (FieldId, msg) -- | Put merely lifts Builder into a Writer monad, applied to (). type Put = PutM () data Get a -- | Run the Put monad with a serialiser runPut :: Put -> ByteString -- | runGet is the simple executor runGet :: Get a -> ByteString -> Result a runGetOnLazy :: Get r -> ByteString -> Either String (r, ByteString) -- | This is runGetOnLazy with the Left results converted to -- error calls and the trailing ByteString discarded. This -- use of runtime errors is discouraged, but may be convenient. getFromBS :: Get r -> ByteString -> r -- | The Wire class is for internal use, and may change. If there is -- a mis-match between the FieldType and the type of b -- then you will get a failure at runtime. -- -- Users should stick to the message functions defined in -- Text.ProtocolBuffers.WireMessage and exported to use user by -- Text.ProtocolBuffers. These are less likely to change. class Wire b where wireGetPacked ft = throwError ("Text.ProtocolBuffers.ProtoCompile.Basic: wireGetPacked default:" ++ "\n\ \ There is no way to get a packed FieldType of " ++ show ft ++ ".\n\ \ Either there is a bug in this library or the wire format is has been updated.") wireSize :: Wire b => FieldType -> b -> WireSize wirePut :: Wire b => FieldType -> b -> Put wireGet :: Wire b => FieldType -> Get b wireGetPacked :: Wire b => FieldType -> Get (Seq b) size'WireTag :: WireTag -> Int64 toWireType :: FieldType -> WireType toWireTag :: FieldId -> FieldType -> WireTag toPackedWireTag :: FieldId -> WireTag mkWireTag :: FieldId -> WireType -> WireTag -- | Used in generated code. prependMessageSize :: WireSize -> WireSize -- | Used in generated code. putSize :: WireSize -> Put putVarUInt :: (Integral a, Bits a) => a -> Put getVarInt :: (Show a, Integral a, Bits a) => Get a -- | Write a lazy ByteString efficiently, simply appending the lazy -- ByteString chunks to the output buffer putLazyByteString :: ByteString -> Put splitWireTag :: WireTag -> (FieldId, WireType) fieldIdOf :: WireTag -> FieldId -- | Used in generated code. wireSizeReq :: Wire v => Int64 -> FieldType -> v -> Int64 -- | Used in generated code. wireSizeOpt :: Wire v => Int64 -> FieldType -> Maybe v -> Int64 -- | Used in generated code. wireSizeRep :: Wire v => Int64 -> FieldType -> Seq v -> Int64 -- | Used in generated code. wireSizePacked :: Wire v => Int64 -> FieldType -> Seq v -> Int64 -- | Used in generated code. wirePutReq :: Wire v => WireTag -> FieldType -> v -> Put -- | Used in generated code. wirePutOpt :: Wire v => WireTag -> FieldType -> Maybe v -> Put -- | Used in generated code. wirePutRep :: Wire v => WireTag -> FieldType -> Seq v -> Put -- | Used in generated code. wirePutPacked :: Wire v => WireTag -> FieldType -> Seq v -> Put wireSizeErr :: Typeable a => FieldType -> a -> WireSize wirePutErr :: Typeable a => FieldType -> a -> Put wireGetErr :: Typeable a => FieldType -> Get a getMessageWith :: (Default message, ReflectDescriptor message) => (WireTag -> message -> Get message) -> Get message -- | Used by generated code getBareMessageWith assumes the wireTag for the -- message, if it existed, has already been read. getBareMessageWith -- assumes that it does needs to read the Varint encoded length of the -- message. getBareMessageWith will consume the entire ByteString it is -- operating on, or until it finds any STOP_GROUP tag (wireType == 4) getBareMessageWith :: (Default message, ReflectDescriptor message) => (WireTag -> message -> Get message) -> Get message wireGetEnum :: (Typeable e, Enum e) => (Int -> Maybe e) -> Get e wireGetPackedEnum :: (Typeable e, Enum e) => (Int -> Maybe e) -> Get (Seq e) unknownField :: Typeable a => a -> FieldId -> Get a unknown :: (Typeable a, ReflectDescriptor a) => FieldId -> WireType -> a -> Get a -- | This reads in the raw bytestring corresponding to an field known only -- through the wiretag's FieldId and WireType. wireGetFromWire :: FieldId -> WireType -> Get ByteString castWord64ToDouble :: Word64 -> Double castWord32ToFloat :: Word32 -> Float castDoubleToWord64 :: Double -> Word64 castFloatToWord32 :: Float -> Word32 zzEncode64 :: Int64 -> Word64 zzEncode32 :: Int32 -> Word32 zzDecode64 :: Word64 -> Int64 zzDecode32 :: Word32 -> Int32 instance Text.ProtocolBuffers.WireMessage.Wire GHC.Types.Double instance Text.ProtocolBuffers.WireMessage.Wire GHC.Types.Float instance Text.ProtocolBuffers.WireMessage.Wire GHC.Int.Int64 instance Text.ProtocolBuffers.WireMessage.Wire GHC.Int.Int32 instance Text.ProtocolBuffers.WireMessage.Wire GHC.Word.Word64 instance Text.ProtocolBuffers.WireMessage.Wire GHC.Word.Word32 instance Text.ProtocolBuffers.WireMessage.Wire GHC.Types.Bool instance Text.ProtocolBuffers.WireMessage.Wire Text.ProtocolBuffers.Basic.Utf8 instance Text.ProtocolBuffers.WireMessage.Wire Data.ByteString.Lazy.Internal.ByteString instance Text.ProtocolBuffers.WireMessage.Wire GHC.Types.Int -- | The Extensions module contributes two main things. The first is -- the definition and implementation of extensible message features. This -- means that the ExtField data type is exported but its -- constructor is (in an ideal world) hidden. -- -- This first part also includes the keys for the extension fields: the -- Key data type. These are typically defined in code generated by -- hprotoc from '.proto' file definitions. -- -- The second main part is the MessageAPI class which defines -- getVal and isSet. These allow uniform access to normal -- and extension fields for users. -- -- Access to extension fields is strictly through keys. There is not -- currently any way to query or change or clear any other extension -- field data. -- -- This module is likely to get broken up into pieces. module Text.ProtocolBuffers.Extensions -- | This allows reflection, in this case it gives the numerical -- FieldId of the key, from 1 to 2^29-1 (excluding 19,000 through -- 19,999). getKeyFieldId :: Key c msg v -> FieldId -- | This allows reflection, in this case it gives the FieldType -- enumeration value (1 to 18) of the -- Text.DescriptorProtos.FieldDescriptorProto.Type of the field. getKeyFieldType :: Key c msg v -> FieldType -- | This will return the default value for a given Key, which is -- set in the '.proto' file, or if unset it is the defaultValue of -- that type. getKeyDefaultValue :: Key c msg v -> v -- | The Key data type is used with the ExtKey class to put, -- get, and clear external fields of messages. The Key can also be -- used with the MessagesAPI to get a possibly default value and -- to check whether a key has been set in a message. -- -- The Key type (opaque to the user) has a phantom type of Maybe -- or Seq that corresponds to Optional or Repeated fields. And a second -- phantom type that matches the message type it must be used with. The -- third type parameter corresponds to the Haskell value type. -- -- The Key is a GADT that puts all the needed class instances into -- scope. The actual content is the FieldId ( numeric key), the -- FieldType (for sanity checks), and Maybe v (a -- non-standard default value). -- -- When code is generated all of the known keys are taken into account in -- the deserialization from the wire. Unknown extension fields are read -- as a collection of raw byte sequences. If a key is then presented it -- will be used to parse the bytes. -- -- There is no guarantee for what happens if two Keys disagree about the -- type of a field; in particular there may be undefined values and -- runtime errors. The data constructor for Key has to be exported -- to the generated code, but is not exposed to the user by -- Text.ProtocolBuffers. data Key c msg v [Key] :: (ExtKey c, ExtendMessage msg, GPB v) => FieldId -> FieldType -> (Maybe v) -> Key c msg v -- | The ExtKey class has three functions for user of the API: -- putExt, getExt, and clearExt. The -- wireGetKey is used in generated code. -- -- There are two instances of this class, Maybe for optional -- message fields and Seq for repeated message fields. This class -- allows for uniform treatment of these two kinds of extension fields. class ExtKey c -- | Change or clear the value of a key in a message. Passing -- Nothing with an optional key or an empty Seq with a -- repeated key clears the value. This function thus maintains the -- invariant that having a field number in the ExtField map means -- that the field is set and not empty. -- -- This should be only way to set the contents of a extension field. putExt :: ExtKey c => Key c msg v -> c v -> msg -> msg -- | Access the key in the message. Optional have type (Key Maybe msg -- v) and return type (Maybe v) while repeated fields have -- type (Key Seq msg v) and return type (Seq v). -- -- There are a few sources of errors with the lookup of the key: -- -- -- -- The failures above should only happen if two different keys are used -- with the same field number. getExt :: ExtKey c => Key c msg v -> msg -> Either String (c v) clearExt :: ExtKey c => Key c msg v -> msg -> msg wireGetKey :: ExtKey c => Key c msg v -> msg -> Get msg class MessageAPI msg a b | msg a -> b where isSet _ _ = True -- | Access data in a message. The first argument is always the message. -- The second argument can be one of 4 categories. -- -- getVal :: MessageAPI msg a b => msg -> a -> b -- | Check whether data is present in the message. -- -- isSet :: MessageAPI msg a b => msg -> a -> Bool -- | The PackedSeq is needed to distinguish the packed repeated -- format from the repeated format. This is only used in the phantom type -- of Key. newtype PackedSeq a PackedSeq :: Seq a -> PackedSeq a [unPackedSeq] :: PackedSeq a -> Seq a data EP EP :: {-# UNPACK #-} !WireType -> !ByteString -> EP -- | This is used by the generated code wireSizeExtField :: ExtField -> WireSize -- | This is used by the generated code. The data is serialized in order of -- increasing field number. wirePutExtField :: ExtField -> Put -- | get a value from the wire into the message's ExtField. This is used by -- generated code for extensions that were not known at compile time. loadExtension :: (ReflectDescriptor a, ExtendMessage a) => FieldId -> WireType -> a -> Get a notExtension :: (ReflectDescriptor a, ExtendMessage a, Typeable a) => FieldId -> WireType -> a -> Get a -- | wireKeyToUnPacked is used to load a repeated packed format into a -- repeated non-packed extension key wireGetKeyToUnPacked :: (ExtendMessage msg, GPB v) => Key Seq msg v -> msg -> Get msg -- | wireKeyToPacked is used to load a repeated unpacked format into a -- repeated packed extension key wireGetKeyToPacked :: (ExtendMessage msg, GPB v) => Key PackedSeq msg v -> msg -> Get msg -- | The Key and GPWitness GADTs use GPB as a -- shorthand for many classes. class (Mergeable a, Default a, Wire a, Show a, Typeable a, Eq a, Ord a) => GPB a -- | ExtField is a newtype'd map from the numeric FieldId key to the -- ExtFieldValue. This allows for the needed class instances. newtype ExtField ExtField :: (Map FieldId ExtFieldValue) -> ExtField -- | ExtendMessage abstracts the operations of storing and -- retrieving the ExtField from the message, and provides the -- reflection needed to know the valid field numbers. -- -- This only used internally. class Typeable msg => ExtendMessage msg getExtField :: ExtendMessage msg => msg -> ExtField putExtField :: ExtendMessage msg => ExtField -> msg -> msg validExtRanges :: ExtendMessage msg => msg -> [(FieldId, FieldId)] -- | The WireType is used to ensure the Seq is homogeneous. The ByteString -- is the unparsed input after the tag. data ExtFieldValue ExtFromWire :: !(Seq EP) -> ExtFieldValue ExtOptional :: !FieldType -> !GPDyn -> ExtFieldValue ExtRepeated :: !FieldType -> !GPDynSeq -> ExtFieldValue ExtPacked :: !FieldType -> !GPDynSeq -> ExtFieldValue instance GHC.Show.Show Text.ProtocolBuffers.Extensions.ExtField instance GHC.Classes.Ord Text.ProtocolBuffers.Extensions.ExtField instance GHC.Classes.Eq Text.ProtocolBuffers.Extensions.ExtField instance GHC.Show.Show Text.ProtocolBuffers.Extensions.ExtFieldValue instance GHC.Classes.Ord Text.ProtocolBuffers.Extensions.ExtFieldValue instance GHC.Show.Show Text.ProtocolBuffers.Extensions.ExtDataPair instance Data.Data.Data Text.ProtocolBuffers.Extensions.ExtDataPair instance GHC.Show.Show Text.ProtocolBuffers.Extensions.EP instance GHC.Classes.Ord Text.ProtocolBuffers.Extensions.EP instance GHC.Classes.Eq Text.ProtocolBuffers.Extensions.EP instance Data.Data.Data Text.ProtocolBuffers.Extensions.EP instance (Data.Typeable.Internal.Typeable c, Text.ProtocolBuffers.Extensions.ExtendMessage msg, Text.ProtocolBuffers.Extensions.GPB v) => GHC.Show.Show (Text.ProtocolBuffers.Extensions.Key c msg v) instance Data.Data.Data Text.ProtocolBuffers.Extensions.ExtField instance Text.ProtocolBuffers.Extensions.ExtendMessage Text.ProtocolBuffers.Extensions.DummyMessageType instance GHC.Classes.Eq Text.ProtocolBuffers.Extensions.ExtFieldValue instance Text.ProtocolBuffers.Extensions.GPB GHC.Types.Bool instance Text.ProtocolBuffers.Extensions.GPB Data.ByteString.Lazy.Internal.ByteString instance Text.ProtocolBuffers.Extensions.GPB Text.ProtocolBuffers.Basic.Utf8 instance Text.ProtocolBuffers.Extensions.GPB GHC.Types.Double instance Text.ProtocolBuffers.Extensions.GPB GHC.Types.Float instance Text.ProtocolBuffers.Extensions.GPB GHC.Int.Int32 instance Text.ProtocolBuffers.Extensions.GPB GHC.Int.Int64 instance Text.ProtocolBuffers.Extensions.GPB GHC.Word.Word32 instance Text.ProtocolBuffers.Extensions.GPB GHC.Word.Word64 instance Text.ProtocolBuffers.Basic.Mergeable Text.ProtocolBuffers.Extensions.ExtField instance Text.ProtocolBuffers.Basic.Default Text.ProtocolBuffers.Extensions.ExtField instance GHC.Classes.Eq Text.ProtocolBuffers.Extensions.GPDyn instance GHC.Classes.Ord Text.ProtocolBuffers.Extensions.GPDyn instance GHC.Show.Show Text.ProtocolBuffers.Extensions.GPDyn instance GHC.Classes.Eq Text.ProtocolBuffers.Extensions.GPDynSeq instance GHC.Classes.Ord Text.ProtocolBuffers.Extensions.GPDynSeq instance GHC.Show.Show Text.ProtocolBuffers.Extensions.GPDynSeq instance Text.ProtocolBuffers.Extensions.ExtKey GHC.Base.Maybe instance Text.ProtocolBuffers.Extensions.ExtKey Data.Sequence.Seq instance Text.ProtocolBuffers.Extensions.ExtKey Text.ProtocolBuffers.Extensions.PackedSeq instance (Text.ProtocolBuffers.Basic.Default msg, Text.ProtocolBuffers.Basic.Default a) => Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> GHC.Base.Maybe a) a instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> Data.Sequence.Seq a) (Data.Sequence.Seq a) instance Text.ProtocolBuffers.Basic.Default v => Text.ProtocolBuffers.Extensions.MessageAPI msg (Text.ProtocolBuffers.Extensions.Key GHC.Base.Maybe msg v) v instance Text.ProtocolBuffers.Basic.Default v => Text.ProtocolBuffers.Extensions.MessageAPI msg (Text.ProtocolBuffers.Extensions.Key Data.Sequence.Seq msg v) (Data.Sequence.Seq v) instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> Data.ByteString.Lazy.Internal.ByteString) Data.ByteString.Lazy.Internal.ByteString instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> Text.ProtocolBuffers.Basic.Utf8) Text.ProtocolBuffers.Basic.Utf8 instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> GHC.Types.Double) GHC.Types.Double instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> GHC.Types.Float) GHC.Types.Float instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> GHC.Int.Int32) GHC.Int.Int32 instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> GHC.Int.Int64) GHC.Int.Int64 instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> GHC.Word.Word32) GHC.Word.Word32 instance Text.ProtocolBuffers.Extensions.MessageAPI msg (msg -> GHC.Word.Word64) GHC.Word.Word64 -- | This module add unknown field support to the library. There are no -- user API things here, except for advanced spelunking into the data -- structures which can and have changed with no notice. Importer beware. module Text.ProtocolBuffers.Unknown -- | This is a suposedly opaque type newtype UnknownField UnknownField :: (Seq UnknownFieldValue) -> UnknownField -- | Messages that can store unknown fields implement this interface. -- UnknownField is a supposedly opaque type. class UnknownMessage msg getUnknownField :: UnknownMessage msg => msg -> UnknownField putUnknownField :: UnknownMessage msg => UnknownField -> msg -> msg data UnknownFieldValue UFV :: {-# UNPACK #-} !WireTag -> !ByteString -> UnknownFieldValue -- | This is used by the generated code wireSizeUnknownField :: UnknownField -> WireSize -- | This is used by the generated code wirePutUnknownField :: UnknownField -> Put -- | This is used by the generated code catch'Unknown :: (Typeable a, UnknownMessage a) => (WireTag -> a -> Get a) -> (WireTag -> a -> Get a) instance Data.Data.Data Text.ProtocolBuffers.Unknown.UnknownField instance GHC.Read.Read Text.ProtocolBuffers.Unknown.UnknownField instance GHC.Show.Show Text.ProtocolBuffers.Unknown.UnknownField instance GHC.Classes.Ord Text.ProtocolBuffers.Unknown.UnknownField instance GHC.Classes.Eq Text.ProtocolBuffers.Unknown.UnknownField instance Data.Data.Data Text.ProtocolBuffers.Unknown.UnknownFieldValue instance GHC.Read.Read Text.ProtocolBuffers.Unknown.UnknownFieldValue instance GHC.Show.Show Text.ProtocolBuffers.Unknown.UnknownFieldValue instance GHC.Classes.Ord Text.ProtocolBuffers.Unknown.UnknownFieldValue instance GHC.Classes.Eq Text.ProtocolBuffers.Unknown.UnknownFieldValue instance Text.ProtocolBuffers.Basic.Mergeable Text.ProtocolBuffers.Unknown.UnknownField instance Text.ProtocolBuffers.Basic.Default Text.ProtocolBuffers.Unknown.UnknownField -- | This provides what is needed for the output of hprotoc to -- compile. This and the Prelude will both be imported qualified as P', -- the prime ensuring no name conflicts are possible. module Text.ProtocolBuffers.Header append :: Seq a -> a -> Seq a emptyBS :: ByteString -- | O(n) Convert a String into a ByteString. pack :: [Char] -> ByteString -- | The fromMaybe function takes a default value and and -- Maybe value. If the Maybe is Nothing, it returns -- the default values; otherwise, it returns the value contained in the -- Maybe. -- --

Examples

-- -- Basic usage: -- --
--   >>> fromMaybe "" (Just "Hello, World!")
--   "Hello, World!"
--   
-- --
--   >>> fromMaybe "" Nothing
--   ""
--   
-- -- Read an integer from a string using readMaybe. If we fail to -- parse an integer, we want to return 0 by default: -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> fromMaybe 0 (readMaybe "5")
--   5
--   
--   >>> fromMaybe 0 (readMaybe "")
--   0
--   
fromMaybe :: a -> Maybe a -> a -- | In many situations, the liftM operations can be replaced by -- uses of ap, which promotes function application. -- --
--   return f `ap` x1 `ap` ... `ap` xn
--   
-- -- is equivalent to -- --
--   liftMn f x1 x2 ... xn
--   
ap :: Monad m => m (a -> b) -> m a -> m b -- | O(n). Build a set from an ascending list of distinct elements -- in linear time. The precondition (input list is strictly ascending) -- is not checked. fromDistinctAscList :: [a] -> Set a -- | O(log n). Is the element in the set? member :: Ord a => a -> Set a -> Bool -- | Is used within a monadic computation to begin exception processing. throwError :: MonadError e m => forall a. e -> m a -- | A handler function to handle previous errors and return to normal -- execution. A common idiom is: -- --
--   do { action1; action2; action3 } `catchError` handler
--   
-- -- where the action functions can call throwError. Note -- that handler and the do-block must have the same return type. catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a -- | choice ps tries to apply the parsers in the list ps -- in order, until one of them succeeds. Returns the value of the -- succeeding parser. choice :: Stream s m t => [ParsecT s u m a] -> ParsecT s u m a -- | sepEndBy p sep parses zero or more occurrences of -- p, separated and optionally ended by sep, ie. -- haskell style statements. Returns a list of values returned by -- p. -- --
--   haskellStatements  = haskellStatement `sepEndBy` semi
--   
sepEndBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a] -- | Skips zero or more white space characters. See also -- skipMany. spaces :: Stream s m Char => ParsecT s u m () -- | The parser try p behaves like parser p, except that -- it pretends that it hasn't consumed any input when an error occurs. -- -- This combinator is used whenever arbitrary look ahead is needed. Since -- it pretends that it hasn't consumed any input when p fails, -- the (<|>) combinator will try its second alternative even -- when the first parser failed while consuming input. -- -- The try combinator can for example be used to distinguish -- identifiers and reserved words. Both reserved words and identifiers -- are a sequence of letters. Whenever we expect a certain reserved word -- where we can also expect an identifier we have to use the try -- combinator. Suppose we write: -- --
--   expr        = letExpr <|> identifier <?> "expression"
--   
--   letExpr     = do{ string "let"; ... }
--   identifier  = many1 letter
--   
-- -- If the user writes "lexical", the parser fails with: unexpected -- 'x', expecting 't' in "let". Indeed, since the (<|>) -- combinator only tries alternatives when the first alternative hasn't -- consumed input, the identifier parser is never tried (because -- the prefix "le" of the string "let" parser is already -- consumed). The right behaviour can be obtained by adding the -- try combinator: -- --
--   expr        = letExpr <|> identifier <?> "expression"
--   
--   letExpr     = do{ try (string "let"); ... }
--   identifier  = many1 letter
--   
try :: ParsecT s u m a -> ParsecT s u m a -- | Text.ProtocolBuffers exposes the client API. This merely -- re-exports parts of the other modules in protocol-buffers. The exposed -- parts are: -- --
--   import Text.ProtocolBuffers.Basic
--     ( Seq,isValidUTF8,toUtf8,utf8,Utf8(Utf8),Int32,Int64,Word32,Word64
--     , WireTag,FieldId,WireType,FieldType,EnumCode,WireSize
--     , Mergeable(mergeAppend,mergeConcat),Default(defaultValue))
--   import Text.ProtocolBuffers.Extensions
--     ( Key,ExtKey(getExt,putExt,clearExt),MessageAPI(getVal,isSet)
--     , getKeyFieldId,getKeyFieldType,getKeyDefaultValue)
--   import Text.ProtocolBuffers.Identifiers
--   import Text.ProtocolBuffers.Reflections
--     ( ReflectDescriptor(..),ReflectEnum(..),ProtoName(..),HsDefault(..),EnumInfoApp
--     , KeyInfo,FieldInfo(..),DescriptorInfo(..),EnumInfo(..),ProtoInfo(..),makePNF )
--   import Text.ProtocolBuffers.TextMessage
--     ( messagePutText, messageGetText )
--   import Text.ProtocolBuffers.WireMessage
--     ( Wire,Put,Get,runPut,runGet,runGetOnLazy
--     , messageSize,messagePut,messageGet,messagePutM,messageGetM
--     , messageWithLengthSize,messageWithLengthPut,messageWithLengthGet,messageWithLengthPutM,messageWithLengthGetM
--     , messageAsFieldSize,messageAsFieldPutM,messageAsFieldGetM)
--   
-- -- The message serialization is taken care of by WireMessage -- operations, especially messagePut and messageGet. The -- MessageAPI provides the useful polymorphic getVal and -- isSet where getVal looks up default values and also -- works with extension keys. The Utf8 newtype is used to indicate -- the format in the underlying lazy ByteString. Messages and -- values can be combined with the right-biased Mergeable -- operations. The mergeEmpty should not be used as required -- values are filled in with undefined errors, please use -- defaultValue instead. -- -- The Utf8 type is a newtype of the Lazy ByteString. It can be safely -- constructed by checking for errors with toUtf8, which returns -- 'Left Int' indicating the index where an error is detected. It can be -- deconstructed with utf8. module Text.ProtocolBuffers