Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module takes care of collecting all the definitions in a .proto file and assigning Haskell names to all of the defined things (messages, enums and field names).
Synopsis
- type Env n = Map Text (Definition n)
- data Definition n
- = Message (MessageInfo n)
- | Enum (EnumInfo n)
- data MessageInfo n = MessageInfo {}
- data ServiceInfo = ServiceInfo {}
- data MethodInfo = MethodInfo {}
- data PlainFieldInfo = PlainFieldInfo {}
- data FieldInfo = FieldInfo {}
- data FieldKind
- data FieldPacking
- data MapEntryInfo = MapEntryInfo {}
- data OneofInfo = OneofInfo {}
- data OneofCase = OneofCase {}
- data FieldName = FieldName {}
- data Symbol
- nameFromSymbol :: Symbol -> Name
- promoteSymbol :: Symbol -> Type
- data EnumInfo n = EnumInfo {}
- data EnumValueInfo n = EnumValueInfo {}
- data EnumUnrecognizedInfo = EnumUnrecognizedInfo {}
- qualifyEnv :: ModuleName -> Env Name -> Env QName
- unqualifyEnv :: Env Name -> Env QName
- collectDefinitions :: FileDescriptorProto -> Env Name
- collectServices :: FileDescriptorProto -> [ServiceInfo]
- definedFieldType :: FieldDescriptorProto -> Env QName -> Definition QName
- definedType :: Text -> Env QName -> Definition QName
- camelCase :: Text -> Text
- overloadedFieldName :: FieldInfo -> Symbol
Documentation
type Env n = Map Text (Definition n) Source #
Env
contains a mapping of proto names (as specified in the .proto file)
to Haskell names. The keys are fully-qualified names, for example,
".package.Message.Submessage". (The protocol_compiler tool emits all
message field types in this form, even if they refer to local definitions.)
The type n
can be either a Name
(when talking about definitions within
the current file) or a (qualified) QName
(when talking about definitions
either from this or another file).
data Definition n Source #
Message (MessageInfo n) | |
Enum (EnumInfo n) |
Instances
Functor Definition Source # | |
Defined in Data.ProtoLens.Compiler.Definitions fmap :: (a -> b) -> Definition a -> Definition b # (<$) :: a -> Definition b -> Definition a # |
data MessageInfo n Source #
All the information needed to define or use a proto message type.
MessageInfo | |
|
Instances
Functor MessageInfo Source # | |
Defined in Data.ProtoLens.Compiler.Definitions fmap :: (a -> b) -> MessageInfo a -> MessageInfo b # (<$) :: a -> MessageInfo b -> MessageInfo a # |
data ServiceInfo Source #
ServiceInfo | |
|
data MethodInfo Source #
MethodInfo | |
|
data PlainFieldInfo Source #
Information about a single field of a proto message, associated with how it is stored.
Information about a single field of a proto message.
How a field is stored inside of the proto message.
RequiredField | A proto2 required field. Stored internally as a value. |
OptionalValueField | A proto3 optional scalar field. Stored internally as a value, and defaults to corresponding instance of fieldDefault. |
OptionalMaybeField | An optional field where the "unset" and "defaulT" values are distinguishable. Stored internally as a Maybe. In particular: proto2 optional fields, proto3 messages, and "oneof" fields. |
RepeatedField FieldPacking | A field containing a sequence of values. Stored internally as either a list or a map, depending on whether the field's FieldDescriptorProto of the field has options.map_entry set. |
MapField MapEntryInfo | A field containing a map of keys to values. Serialized as a repeated field of an autogenerated "entry" proto type, each instance of which contains a key-value pair. |
data FieldPacking Source #
NotPackable | Cannot be packed (e.g., strings or messages). |
Packable | Can be decoded as packed, but should not be not be encoded as packed by default. |
Packed | Can be decoded as packed, and should be encoded as packed by default. |
Instances
Eq FieldPacking Source # | |
Defined in Data.ProtoLens.Compiler.Definitions (==) :: FieldPacking -> FieldPacking -> Bool # (/=) :: FieldPacking -> FieldPacking -> Bool # |
data MapEntryInfo Source #
The "entry" type for a map field is a proto message, autogenerated by protoc, that has two fields: a key and a value. The map field should be serialized like a repeated field of the entry messages.
MapEntryInfo | |
|
OneofInfo | |
|
OneofCase | |
|
FieldName | |
|
A string that refers to the name (in Haskell) of a lens that accesses a field.
For example, in the signature of the overloaded lens
foo :: HasLens "foo" ... => Lens ...
a Symbol
is used to construct both the type-level argument to
HasLens
and the name of the function foo
.
nameFromSymbol :: Symbol -> Name Source #
promoteSymbol :: Symbol -> Type Source #
Construct a promoted, type-level string.
All the information needed to define or use a proto enum type.
data EnumValueInfo n Source #
Information about a single value case of a proto enum.
Instances
Functor EnumValueInfo Source # | |
Defined in Data.ProtoLens.Compiler.Definitions fmap :: (a -> b) -> EnumValueInfo a -> EnumValueInfo b # (<$) :: a -> EnumValueInfo b -> EnumValueInfo a # |
data EnumUnrecognizedInfo Source #
Information about the "unrecognized" case of an enum.
qualifyEnv :: ModuleName -> Env Name -> Env QName Source #
collectDefinitions :: FileDescriptorProto -> Env Name Source #
Collect all the definitions in the given file (including definitions nested in other messages), and assign Haskell names to them.
definedFieldType :: FieldDescriptorProto -> Env QName -> Definition QName Source #
Look up the Haskell name for the type of a given field (message or enum).
definedType :: Text -> Env QName -> Definition QName Source #
Look up the Haskell name for the type of a given type.