-- 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
--   <a>Data.Binary.Strict.IncrementalGet</a> with slightly better
--   internals. The simplified <a>Get</a>, <a>runGet</a>, <a>Result</a>
--   trio with the <a>Data.Binary.Strict.Class.BinaryParser</a> instance
--   are an _untested_ upgrade from IncrementalGet. Especially untested are
--   the strictness properties.
--   
--   <a>Get</a> usefully implements Applicative and Monad, MonadError,
--   Alternative and MonadPlus. Unhandled errors are reported along with
--   the number of bytes successfully consumed. Effects of <a>suspend</a>
--   and <a>putAvailable</a> are visible after fail<i>throwError</i>mzero.
--   
--   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.
--   
--   <a>suspendUntilComplete</a> repeatedly uses a partial continuation to
--   ask for more input until <a>Nothing</a> is passed and then it proceeds
--   with parsing.
--   
--   The <a>getAvailable</a> command returns the lazy byte string the
--   parser has remaining before calling <a>suspend</a>. The
--   <a>putAvailable</a> 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
--   fail<i>throwError</i>mzero.
--   
--   The three <a>lookAhead</a> and <a>lookAheadM</a> and <a>lookAheadE</a>
--   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

-- | <a>runGet</a> is the simple executor
runGet :: Get a -> ByteString -> Result a

-- | <a>runGetAll</a> 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 <tt>n</tt> 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 <tt>n</tt> bytes from the input, as a lazy ByteString. This will
--   suspend if there is too little data.
getLazyByteString :: Int64 -> Get ByteString

-- | Keep calling <a>suspend</a> until Nothing is passed to the
--   <a>Partial</a> 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

-- | <a>putAvailable</a> 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 : <a>putAvailable</a> is still untested.
putAvailable :: ByteString -> Get ()

-- | <a>lookAhead</a> runs the <tt>todo</tt> action and then rewinds only
--   the BinaryParser state. Any new input from <a>suspend</a> or changes
--   from <a>putAvailable</a> 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

-- | <a>lookAheadM</a> runs the <tt>todo</tt> action. If the action returns
--   <a>Nothing</a> then the BinaryParser state is rewound (as in
--   <a>lookAhead</a>). If the action return <a>Just</a> 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)

-- | <a>lookAheadE</a> runs the <tt>todo</tt> action. If the action returns
--   <a>Left</a> then the BinaryParser state is rewound (as in
--   <a>lookAhead</a>). If the action return <a>Right</a> 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 <tt>m</tt> bytes
skip :: Int64 -> Get ()

-- | Return the number of <a>bytesRead</a> so far. Initially 0, never
--   negative.
bytesRead :: Get Int64

-- | Return True if the number of bytes <a>remaining</a> is 0. Any futher
--   attempts to read an empty parser will call <a>suspend</a> which might
--   result in more input to consume.
--   
--   Compare with <a>isReallyEmpty</a>
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 <a>isEmpty</a>
isReallyEmpty :: Get Bool

-- | Return the number of bytes <a>remaining</a> before the current input
--   runs out and <a>suspend</a> 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 <tt>n</tt> 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


-- | <a>Text.ProtocolBuffers.Basic</a> defines or re-exports most of the
--   basic field types; <a>Maybe</a>,<a>Bool</a>, <a>Double</a>, and
--   <a>Float</a> come from the Prelude instead. This module also defines
--   the <a>Mergeable</a> and <a>Default</a> classes. The <tt>Wire</tt>
--   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 <a>Maybe</a> type encapsulates an optional value. A value of type
--   <tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>
--   (represented as <tt><a>Just</a> a</tt>), or it is empty (represented
--   as <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with
--   errors or exceptional cases without resorting to drastic measures such
--   as <a>error</a>.
--   
--   The <a>Maybe</a> type is also a monad. It is a simple kind of error
--   monad, where all errors are represented by <a>Nothing</a>. A richer
--   error monad can be built using the <a>Either</a> type.
data Maybe a :: * -> *

-- | General-purpose finite sequences.
data Seq a :: * -> *

-- | <a>Utf8</a> is used to mark <a>ByteString</a> values that (should)
--   contain valid utf8 encoded strings. This type is used to represent
--   <tt>TYPE_STRING</tt> values.
newtype Utf8
Utf8 :: ByteString -> Utf8

-- | A space-efficient representation of a <a>Word8</a> vector, supporting
--   many efficient operations.
--   
--   A lazy <a>ByteString</a> contains 8-bit bytes, or by using the
--   operations from <a>Data.ByteString.Lazy.Char8</a> 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 :: *

-- | <a>WireTag</a> is the 32 bit value with the upper 29 bits being the
--   <a>FieldId</a> and the lower 3 bits being the <a>WireType</a>
newtype WireTag
WireTag :: Word32 -> WireTag
[getWireTag] :: WireTag -> Word32

-- | <a>FieldId</a> 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

-- | <a>WireType</a> is the 3 bit wire encoding value, and is currently in
--   the range 0 to 5, leaving 6 and 7 currently invalid.
--   
--   <ul>
--   <li>0 <i>Varint</i> : int32, int64, uint32, uint64, sint32, sint64,
--   bool, enum</li>
--   <li>1 <i>64-bit</i> : fixed64, sfixed64, double</li>
--   <li>2 <i>Length-delimited</i> : string, bytes, embedded messages</li>
--   <li>3 <i>Start group</i> : groups (deprecated)</li>
--   <li>4 <i>End group</i> : groups (deprecated)</li>
--   <li>5 <i>32-bit</i> : fixed32, sfixed32, float</li>
--   </ul>
newtype WireType
WireType :: Word32 -> WireType
[getWireType] :: WireType -> Word32

-- | <a>FieldType</a> is the integer associated with the
--   FieldDescriptorProto's Type. The allowed range is currently 1 to 18,
--   as shown below (excerpt from descritor.proto)
--   
--   <pre>
--   // 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.
--   </pre>
newtype FieldType
FieldType :: Int -> FieldType
[getFieldType] :: FieldType -> Int

-- | <a>EnumCode</a> 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

-- | <a>WireSize</a> is the Int64 size type associated with the lazy
--   bytestrings used in the <tt>Put</tt> and <tt>Get</tt> monads.
type WireSize = Int64

-- | The <a>Mergeable</a> class is not a <a>Monoid</a>, <tt>mergeEmpty</tt>
--   is not a left or right unit like <a>mempty</a>. The default
--   <a>mergeAppend</a> is to take the second parameter and discard the
--   first one. The <a>mergeConcat</a> defaults to <tt>foldl</tt>
--   associativity.
--   
--   NOTE: <tt>mergeEmpty</tt> has been removed in protocol buffers version
--   2. Use <a>defaultValue</a> instead. New strict fields would mean that
--   required fields in messages will be automatic errors with
--   <tt>mergeEmpty</tt>.
class Default a => Mergeable a where mergeAppend _a b = b mergeConcat = foldl mergeAppend defaultValue

-- | <a>mergeAppend</a> 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

-- | <a>mergeConcat</a> is <tt> F.foldl mergeAppend defaultValue </tt> 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
--   <a>http://code.google.com/apis/protocolbuffers/docs/proto.html#optional</a>
--   and also note that <a>Enum</a> types have a <a>defaultValue</a> that
--   is the first one in the <tt>.proto</tt> file (there is always at least
--   one value). Instances of this for messages hold any default value
--   defined in the <tt>.proto</tt> file. <a>defaultValue</a> is where the
--   <tt>MessageAPI</tt> function <tt>getVal</tt> looks when an optional
--   field is not set.
class Default a

-- | The <a>defaultValue</a> is never undefined or an error to evalute.
--   This makes it much more useful compared to <tt>mergeEmpty</tt>. In a
--   default message all Optional field values are set to <a>Nothing</a>
--   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 <a>Utf8</a> tagged lazy bytestrings.
--   
--   An <tt>identifier</tt> is a non-empty ASCII string made of
--   [a-zA-Z0-9_] where the first character is never in [0-9].
--   
--   A <tt>field</tt> 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 <a>U'_</a> 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

-- | <a>.</a> separated identifier which may or may start with a dot. There
--   are never two or more <a>.</a>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 (<a>.</a> 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 <a>.</a>, 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 <a>.</a>, 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 <a>validDI</a>.
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)

-- | <a>validDI</a> ensures the DIName is
validDI :: Dotted a => a -> Maybe (DIName a)

-- | <a>split</a> returns a list of non-empty <tt>a</tt> with all <a>.</a>
--   characters removed
split :: Dotted a => a -> [a]

-- | The <a>mangle</a> transformation has instances for several
--   combiantions of input and output. These allow one to construct the
--   Haskell types of MName<i>FMName</i>PMName and FName<i>FFName</i>PFName
--   out of the protobuf types IName<i>DIName</i>FIName. 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

-- | <a>difi</a> examines the <a>DIName</a> and prepend a <a>.</a> if
--   absent, promoting it to a <a>FIName</a>.
difi :: Dotted a => DIName a -> FIName a

-- | Typed <a>split</a>
splitDI :: Dotted a => DIName a -> [IName a]

-- | Typed <a>split</a>
splitFI :: Dotted a => FIName a -> [IName a]

-- | Typed <a>split</a>
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 <a>.</a>)
--   
--   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 <a>.</a>)
--   
--   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 <tt>hprotoc</tt>. 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 <tt>fileDescriptorProto</tt> 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
--   <a>haskellPrefix</a> was possibly specified on the <tt>hprotoc</tt>
--   command line. The <a>parentModule</a> 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
--   <a>baseName</a> started with an uppercase letter, in <tt> ['A'..'Z']
--   </tt>.
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)

-- | <a>HsDefault</a> stores the parsed default from the proto file in a
--   form that will make a nice literal in the
--   <a>Language.Haskell.Exts.Syntax</a> code generation by
--   <tt>hprotoc</tt>.
--   
--   Note that Utf8 labeled byte sequences have been stripped to just
--   <a>ByteString</a> here as this is sufficient for code generation.
--   
--   On 25 August 2010 20:12, George van den Driessche
--   <a>georgevdd@google.com</a> 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

-- | <a>SomeRealFloat</a> 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 <a>read</a> on the stored <a>show</a> output of
--   the <a>DescriptorInfo</a> 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

-- | <a>GetMessageInfo</a> is used in getting messages from the wire. It
--   supplies the <a>Set</a> of precomposed wire tags that must be found in
--   the message as well as a <a>Set</a> 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 <a>ByteString</a> 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

-- | <a>makePNF</a> 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 <a>String</a>
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
--   <a>http://code.google.com/apis/protocolbuffers/docs/encoding.html</a>.
--   
--   The user API functions are grouped into sections and documented. The
--   rest are for internal use. The main functions are <a>messageGet</a>
--   and <a>messagePut</a> (and <a>messageSize</a>). 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 <a>runPut</a> applied to <a>messagePutM</a>. It result in a
--   <a>ByteString</a> with a length of <a>messageSize</a> bytes.
messagePut :: (ReflectDescriptor msg, Wire msg) => msg -> ByteString

-- | This consumes the <a>ByteString</a> to decode a message. It assumes
--   the <a>ByteString</a> 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 <a>ByteString</a> past the end of the stop tag
--   is returned as well.
--   
--   This is <a>runGetOnLazy</a> applied to <a>messageGetM</a>.
messageGet :: (ReflectDescriptor msg, Wire msg) => ByteString -> Either String (msg, ByteString)

-- | This writes just the message's fields with tags to the wire. This
--   <a>Put</a> monad can be composed and eventually executed with
--   <a>runPut</a>.
--   
--   This is actually <tt> wirePut 10 msg </tt>
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 <tt> wireGet 10 msg </tt>
messageGetM :: (ReflectDescriptor msg, Wire msg) => Get msg

-- | This computes the size of the message fields as in <a>messageSize</a>
--   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 <a>runPut</a> applied to <a>messageWithLengthPutM</a>. It
--   results in a <a>ByteString</a> with a length of
--   <a>messageWithLengthSize</a> bytes.
messageWithLengthPut :: (ReflectDescriptor msg, Wire msg) => msg -> ByteString

-- | This <a>runGetOnLazy</a> applied to <a>messageWithLengthGetM</a>.
--   
--   This first reads the encoded length of the message and will then
--   succeed when it has consumed precisely this many additional bytes. The
--   <a>ByteString</a> 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 <a>Put</a> monad can be
--   composed and eventually executed with <a>runPut</a>.
--   
--   This is actually <tt> wirePut 11 msg </tt>
messageWithLengthPutM :: (ReflectDescriptor msg, Wire msg) => msg -> Put

-- | This reads the encoded message length and then the message.
--   
--   This is actually <tt> wireGet 11 msg </tt>
messageWithLengthGetM :: (ReflectDescriptor msg, Wire msg) => Get msg

-- | This computes the size of the <a>messageWithLengthSize</a> and then
--   adds the length an initial tag with the given <a>FieldId</a>.
messageAsFieldSize :: (ReflectDescriptor msg, Wire msg) => FieldId -> msg -> WireSize

-- | This writes an encoded wire tag with the given <a>FieldId</a> and then
--   the encoded length of the message's fields and then the message's
--   fields with tags to the wire. This <a>Put</a> monad can be composed
--   and eventually executed with <a>runPut</a>.
messageAsFieldPutM :: (ReflectDescriptor msg, Wire msg) => FieldId -> msg -> Put

-- | This reads a wire tag (must be of type '2') to get the <a>FieldId</a>.
--   Then the encoded message length is read, followed by the message
--   itself. Both the <a>FieldId</a> 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 <a>Put</a> monad with a serialiser
runPut :: Put -> ByteString

-- | <a>runGet</a> is the simple executor
runGet :: Get a -> ByteString -> Result a
runGetOnLazy :: Get r -> ByteString -> Either String (r, ByteString)

-- | This is <a>runGetOnLazy</a> with the <a>Left</a> results converted to
--   <a>error</a> calls and the trailing <a>ByteString</a> discarded. This
--   use of runtime errors is discouraged, but may be convenient.
getFromBS :: Get r -> ByteString -> r

-- | The <a>Wire</a> class is for internal use, and may change. If there is
--   a mis-match between the <a>FieldType</a> and the type of <tt>b</tt>
--   then you will get a failure at runtime.
--   
--   Users should stick to the message functions defined in
--   <a>Text.ProtocolBuffers.WireMessage</a> and exported to use user by
--   <a>Text.ProtocolBuffers</a>. 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 <a>FieldId</a> and <a>WireType</a>.
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 <a>Extensions</a> module contributes two main things. The first is
--   the definition and implementation of extensible message features. This
--   means that the <a>ExtField</a> 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
--   <a>Key</a> data type. These are typically defined in code generated by
--   <tt>hprotoc</tt> from '.proto' file definitions.
--   
--   The second main part is the <a>MessageAPI</a> class which defines
--   <a>getVal</a> and <a>isSet</a>. 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
--   <a>FieldId</a> 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 <a>FieldType</a>
--   enumeration value (1 to 18) of the
--   <a>Text.DescriptorProtos.FieldDescriptorProto.Type</a> of the field.
getKeyFieldType :: Key c msg v -> FieldType

-- | This will return the default value for a given <a>Key</a>, which is
--   set in the '.proto' file, or if unset it is the <a>defaultValue</a> of
--   that type.
getKeyDefaultValue :: Key c msg v -> v

-- | The <a>Key</a> data type is used with the <a>ExtKey</a> class to put,
--   get, and clear external fields of messages. The <a>Key</a> can also be
--   used with the <tt>MessagesAPI</tt> to get a possibly default value and
--   to check whether a key has been set in a message.
--   
--   The <a>Key</a> 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 <a>Key</a> is a GADT that puts all the needed class instances into
--   scope. The actual content is the <a>FieldId</a> ( numeric key), the
--   <a>FieldType</a> (for sanity checks), and <tt>Maybe v</tt> (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 <a>Key</a> has to be exported
--   to the generated code, but is not exposed to the user by
--   <a>Text.ProtocolBuffers</a>.
data Key c msg v
[Key] :: (ExtKey c, ExtendMessage msg, GPB v) => FieldId -> FieldType -> (Maybe v) -> Key c msg v

-- | The <a>ExtKey</a> class has three functions for user of the API:
--   <a>putExt</a>, <a>getExt</a>, and <a>clearExt</a>. The
--   <a>wireGetKey</a> is used in generated code.
--   
--   There are two instances of this class, <a>Maybe</a> for optional
--   message fields and <a>Seq</a> 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
--   <a>Nothing</a> with an optional key or an empty <a>Seq</a> with a
--   repeated key clears the value. This function thus maintains the
--   invariant that having a field number in the <a>ExtField</a> 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 <tt>(Key Maybe msg
--   v)</tt> and return type <tt>(Maybe v)</tt> while repeated fields have
--   type <tt>(Key Seq msg v)</tt> and return type <tt>(Seq v)</tt>.
--   
--   There are a few sources of errors with the lookup of the key:
--   
--   <ul>
--   <li>It may find unparsed bytes from loading the message. <a>getExt</a>
--   will attempt to parse the bytes as the key's value type, and may fail.
--   The parsing is done with the <tt>parseWireExt</tt> method (which is
--   not exported to user API).</li>
--   <li>The wrong optional-key versus repeated-key type is a failure</li>
--   <li>The wrong type of the value might be found in the map and</li>
--   <li>cause a failure</li>
--   </ul>
--   
--   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.
--   
--   <ul>
--   <li>The field name of a required field acts a simple retrieval of the
--   data from the message.</li>
--   <li>The field name of an optional field will retreive the data if it
--   is set or lookup the default value if it is not set.</li>
--   <li>The field name of a repeated field always retrieves the (possibly
--   empty) <a>Seq</a> of values.</li>
--   <li>A Key for an optional or repeated value will act as the field name
--   does above, but if there is a type mismatch or parse error it will use
--   the defaultValue for optional types and an empty sequence for repeated
--   types.</li>
--   </ul>
getVal :: MessageAPI msg a b => msg -> a -> b

-- | Check whether data is present in the message.
--   
--   <ul>
--   <li>Required fields always return <a>True</a>.</li>
--   <li>Optional fields return whether a value is present.</li>
--   <li>Repeated field return <a>False</a> if there are no values,
--   otherwise they return <a>True</a>.</li>
--   <li>Keys return as optional or repeated, but checks only if the field
--   # is present. This assumes that there are no collisions where more
--   that one key refers to the same field number of this message
--   type.</li>
--   </ul>
isSet :: MessageAPI msg a b => msg -> a -> Bool

-- | The <a>PackedSeq</a> 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 <a>Key</a> and <tt>GPWitness</tt> GADTs use <a>GPB</a> 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

-- | <a>ExtendMessage</a> abstracts the operations of storing and
--   retrieving the <a>ExtField</a> 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 <tt>hprotoc</tt> 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

-- | <i>O(n)</i> Convert a <a>String</a> into a <a>ByteString</a>.
pack :: [Char] -> ByteString

-- | The <a>fromMaybe</a> function takes a default value and and
--   <a>Maybe</a> value. If the <a>Maybe</a> is <a>Nothing</a>, it returns
--   the default values; otherwise, it returns the value contained in the
--   <a>Maybe</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; fromMaybe "" (Just "Hello, World!")
--   "Hello, World!"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fromMaybe "" Nothing
--   ""
--   </pre>
--   
--   Read an integer from a string using <tt>readMaybe</tt>. If we fail to
--   parse an integer, we want to return <tt>0</tt> by default:
--   
--   <pre>
--   &gt;&gt;&gt; import Text.Read ( readMaybe )
--   
--   &gt;&gt;&gt; fromMaybe 0 (readMaybe "5")
--   5
--   
--   &gt;&gt;&gt; fromMaybe 0 (readMaybe "")
--   0
--   </pre>
fromMaybe :: a -> Maybe a -> a

-- | In many situations, the <a>liftM</a> operations can be replaced by
--   uses of <a>ap</a>, which promotes function application.
--   
--   <pre>
--   return f `ap` x1 `ap` ... `ap` xn
--   </pre>
--   
--   is equivalent to
--   
--   <pre>
--   liftMn f x1 x2 ... xn
--   </pre>
ap :: Monad m => m (a -> b) -> m a -> m b

-- | <i>O(n)</i>. Build a set from an ascending list of distinct elements
--   in linear time. <i>The precondition (input list is strictly ascending)
--   is not checked.</i>
fromDistinctAscList :: [a] -> Set a

-- | <i>O(log n)</i>. 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:
--   
--   <pre>
--   do { action1; action2; action3 } `catchError` handler
--   </pre>
--   
--   where the <tt>action</tt> functions can call <a>throwError</a>. Note
--   that <tt>handler</tt> and the do-block must have the same return type.
catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a

-- | <tt>choice ps</tt> tries to apply the parsers in the list <tt>ps</tt>
--   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

-- | <tt>sepEndBy p sep</tt> parses <i>zero</i> or more occurrences of
--   <tt>p</tt>, separated and optionally ended by <tt>sep</tt>, ie.
--   haskell style statements. Returns a list of values returned by
--   <tt>p</tt>.
--   
--   <pre>
--   haskellStatements  = haskellStatement `sepEndBy` semi
--   </pre>
sepEndBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

-- | Skips <i>zero</i> or more white space characters. See also
--   <a>skipMany</a>.
spaces :: Stream s m Char => ParsecT s u m ()

-- | The parser <tt>try p</tt> behaves like parser <tt>p</tt>, 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 <tt>p</tt> fails,
--   the (<a>&lt;|&gt;</a>) combinator will try its second alternative even
--   when the first parser failed while consuming input.
--   
--   The <tt>try</tt> 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 <tt>try</tt>
--   combinator. Suppose we write:
--   
--   <pre>
--   expr        = letExpr &lt;|&gt; identifier &lt;?&gt; "expression"
--   
--   letExpr     = do{ string "let"; ... }
--   identifier  = many1 letter
--   </pre>
--   
--   If the user writes "lexical", the parser fails with: <tt>unexpected
--   'x', expecting 't' in "let"</tt>. Indeed, since the (<a>&lt;|&gt;</a>)
--   combinator only tries alternatives when the first alternative hasn't
--   consumed input, the <tt>identifier</tt> parser is never tried (because
--   the prefix "le" of the <tt>string "let"</tt> parser is already
--   consumed). The right behaviour can be obtained by adding the
--   <tt>try</tt> combinator:
--   
--   <pre>
--   expr        = letExpr &lt;|&gt; identifier &lt;?&gt; "expression"
--   
--   letExpr     = do{ try (string "let"); ... }
--   identifier  = many1 letter
--   </pre>
try :: ParsecT s u m a -> ParsecT s u m a


-- | <a>Text.ProtocolBuffers</a> exposes the client API. This merely
--   re-exports parts of the other modules in protocol-buffers. The exposed
--   parts are:
--   
--   <pre>
--   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)
--   </pre>
--   
--   The message serialization is taken care of by <a>WireMessage</a>
--   operations, especially <a>messagePut</a> and <a>messageGet</a>. The
--   <a>MessageAPI</a> provides the useful polymorphic <a>getVal</a> and
--   <a>isSet</a> where <a>getVal</a> looks up default values and also
--   works with extension keys. The <a>Utf8</a> newtype is used to indicate
--   the format in the underlying lazy <tt>ByteString</tt>. Messages and
--   values can be combined with the right-biased <a>Mergeable</a>
--   operations. The <tt>mergeEmpty</tt> should not be used as required
--   values are filled in with undefined errors, please use
--   <a>defaultValue</a> instead.
--   
--   The Utf8 type is a newtype of the Lazy ByteString. It can be safely
--   constructed by checking for errors with <a>toUtf8</a>, which returns
--   'Left Int' indicating the index where an error is detected. It can be
--   deconstructed with <a>utf8</a>.
module Text.ProtocolBuffers
