proto-lens-protoc-0.2.2.2: Protocol buffer compiler for the proto-lens library.

Data.ProtoLens.Compiler.Definitions

Description

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

# 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 #

Constructors

 Message (MessageInfo n) Enum (EnumInfo n)

Instances

 Source # Methodsfmap :: (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. Constructors  MessageInfo FieldsmessageName :: nHaskell type namemessageDescriptor :: DescriptorProto messageFields :: [FieldInfo]Fields not belonging to a oneof.messageOneofFields :: [OneofInfo]The oneofs in this message, associated with the fields that belong to them. Instances  Source # Methodsfmap :: (a -> b) -> MessageInfo a -> MessageInfo b #(<$) :: a -> MessageInfo b -> MessageInfo a #

data FieldInfo Source #

Information about a single field of a proto message.

Constructors

 FieldInfo Fields

data OneofInfo Source #

Constructors

 OneofInfo FieldsoneofFieldName :: FieldName oneofTypeName :: NameThe name of the sum type corresponding to this oneof.oneofCases :: [OneofCase]The individual fields that make up this oneof.

data OneofCase Source #

Constructors

 OneofCase FieldscaseField :: FieldInfo caseConstructorName :: NameThe constructor for building a oneofTypeName from the value in this field.

data FieldName Source #

Constructors

 FieldName FieldsoverloadedName :: SymbolThe overloaded name of lenses that access this field. For example, if the field is called "foo_bar" in the .proto then overloadedName == "fooBar" and we might generate fooBar and/or maybe'fooBar lenses to access the data.May be shared between two different message data types in the same module.haskellRecordFieldName :: NameThe Haskell name of this internal record field; for example, "_FooBarbaz. Unique within each module.

data Symbol Source #

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.

Instances

 Source # Methods(==) :: Symbol -> Symbol -> Bool #(/=) :: Symbol -> Symbol -> Bool # Source # Methods(<) :: Symbol -> Symbol -> Bool #(<=) :: Symbol -> Symbol -> Bool #(>) :: Symbol -> Symbol -> Bool #(>=) :: Symbol -> Symbol -> Bool #max :: Symbol -> Symbol -> Symbol #min :: Symbol -> Symbol -> Symbol # Source # Methods Source # Methodsmconcat :: [Symbol] -> Symbol #

Construct a promoted, type-level string.

data EnumInfo n Source #

All the information needed to define or use a proto enum type.

Constructors

 EnumInfo FieldsenumName :: n enumDescriptor :: EnumDescriptorProto enumValues :: [EnumValueInfo n]

Instances

 Source # Methodsfmap :: (a -> b) -> EnumInfo a -> EnumInfo b #(<$) :: a -> EnumInfo b -> EnumInfo a # data EnumValueInfo n Source # Information about a single value case of a proto enum. Constructors  EnumValueInfo FieldsenumValueName :: n enumValueDescriptor :: EnumValueDescriptorProto enumAliasOf :: Maybe NameIf Nothing, we turn value into a normal constructor of the enum. If Just n, we're treating it as an alias of the constructor n (a PatternSynonym in Haskell). This mirrors the behavior of the Java API. Instances  Source # Methodsfmap :: (a -> b) -> EnumValueInfo a -> EnumValueInfo b #(<$) :: a -> EnumValueInfo b -> EnumValueInfo a #

Collect all the definitions in the given file (including definitions nested in other messages), and assign Haskell names to them.

Look up the Haskell name for the type of a given field (message or enum).