Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class Pretty a where
- pPrintPrec :: PrettyLevel -> Rational -> a -> Doc
- pPrint :: a -> Doc
- pPrintList :: PrettyLevel -> [a] -> Doc
- data DotProtoReservedField
- data DotProtoField
- data DotProtoMessagePart
- data RPCMethod = RPCMethod {}
- data DotProtoServicePart
- data Streaming
- data DotProtoEnumPart
- type DotProtoEnumValue = Int32
- data DotProtoType
- data Packing
- data DotProtoPrimType
- data DotProtoValue
- data DotProto = DotProto {}
- data DotProtoMeta = DotProtoMeta {}
- data DotProtoDefinition
- data DotProtoOption = DotProtoOption {}
- data DotProtoPackageSpec
- data DotProtoImportQualifier
- data DotProtoImport = DotProtoImport {}
- data DotProtoIdentifier
- newtype Path = Path {}
- newtype PackageName = PackageName {}
- newtype FieldName = FieldName {}
- newtype MessageName = MessageName {}
- fakePath :: Path
- parseProto :: Path -> String -> Either ParseError DotProto
- parseProtoFile :: MonadIO m => Path -> FilePath -> m (Either ParseError DotProto)
- typeLikeName :: MonadError CompileError m => String -> m String
- fieldLikeName :: String -> String
- prefixedEnumFieldName :: String -> String -> String
- data RenderingOptions = RenderingOptions {}
- defRenderingOptions :: RenderingOptions
- defSelectorName :: DotProtoIdentifier -> DotProtoIdentifier -> FieldNumber -> Doc
- defEnumMemberName :: DotProtoIdentifier -> DotProtoIdentifier -> Doc
- renderDotProto :: RenderingOptions -> DotProto -> Doc
- toProtoFile :: RenderingOptions -> DotProto -> String
- toProtoFileDef :: DotProto -> String
- packageFromDefs :: String -> [DotProtoDefinition] -> DotProto
Documentation
Pretty printing class. The precedence level is used in a similar way as in
the Show
class. Minimal complete definition is either pPrintPrec
or
pPrint
.
pPrintPrec :: PrettyLevel -> Rational -> a -> Doc #
pPrintList :: PrettyLevel -> [a] -> Doc #
Instances
data DotProtoReservedField Source #
Instances
Eq DotProtoReservedField Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoReservedField -> DotProtoReservedField -> Bool # (/=) :: DotProtoReservedField -> DotProtoReservedField -> Bool # | |
Show DotProtoReservedField Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoReservedField -> ShowS # show :: DotProtoReservedField -> String # showList :: [DotProtoReservedField] -> ShowS # | |
Arbitrary DotProtoReservedField Source # | |
Defined in Proto3.Suite.DotProto.AST | |
Pretty DotProtoReservedField Source # | |
Defined in Proto3.Suite.DotProto.Rendering pPrintPrec :: PrettyLevel -> Rational -> DotProtoReservedField -> Doc # pPrint :: DotProtoReservedField -> Doc # pPrintList :: PrettyLevel -> [DotProtoReservedField] -> Doc # |
data DotProtoField Source #
Instances
Eq DotProtoField Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoField -> DotProtoField -> Bool # (/=) :: DotProtoField -> DotProtoField -> Bool # | |
Show DotProtoField Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoField -> ShowS # show :: DotProtoField -> String # showList :: [DotProtoField] -> ShowS # | |
Arbitrary DotProtoField Source # | |
Defined in Proto3.Suite.DotProto.AST arbitrary :: Gen DotProtoField # shrink :: DotProtoField -> [DotProtoField] # |
data DotProtoMessagePart Source #
DotProtoMessageField DotProtoField | |
DotProtoMessageOneOf DotProtoIdentifier [DotProtoField] | |
DotProtoMessageDefinition DotProtoDefinition | |
DotProtoMessageReserved [DotProtoReservedField] |
Instances
Eq DotProtoMessagePart Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoMessagePart -> DotProtoMessagePart -> Bool # (/=) :: DotProtoMessagePart -> DotProtoMessagePart -> Bool # | |
Show DotProtoMessagePart Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoMessagePart -> ShowS # show :: DotProtoMessagePart -> String # showList :: [DotProtoMessagePart] -> ShowS # | |
Arbitrary DotProtoMessagePart Source # | |
Defined in Proto3.Suite.DotProto.AST |
data DotProtoServicePart Source #
Instances
Eq DotProtoServicePart Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoServicePart -> DotProtoServicePart -> Bool # (/=) :: DotProtoServicePart -> DotProtoServicePart -> Bool # | |
Show DotProtoServicePart Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoServicePart -> ShowS # show :: DotProtoServicePart -> String # showList :: [DotProtoServicePart] -> ShowS # | |
Arbitrary DotProtoServicePart Source # | |
Defined in Proto3.Suite.DotProto.AST | |
Pretty DotProtoServicePart Source # | |
Defined in Proto3.Suite.DotProto.Rendering pPrintPrec :: PrettyLevel -> Rational -> DotProtoServicePart -> Doc # pPrint :: DotProtoServicePart -> Doc # pPrintList :: PrettyLevel -> [DotProtoServicePart] -> Doc # |
data DotProtoEnumPart Source #
DotProtoEnumField DotProtoIdentifier DotProtoEnumValue [DotProtoOption] | |
DotProtoEnumOption DotProtoOption | |
DotProtoEnumEmpty |
Instances
Eq DotProtoEnumPart Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoEnumPart -> DotProtoEnumPart -> Bool # (/=) :: DotProtoEnumPart -> DotProtoEnumPart -> Bool # | |
Show DotProtoEnumPart Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoEnumPart -> ShowS # show :: DotProtoEnumPart -> String # showList :: [DotProtoEnumPart] -> ShowS # | |
Arbitrary DotProtoEnumPart Source # | |
Defined in Proto3.Suite.DotProto.AST arbitrary :: Gen DotProtoEnumPart # shrink :: DotProtoEnumPart -> [DotProtoEnumPart] # |
type DotProtoEnumValue = Int32 Source #
data DotProtoType Source #
This type is an almagamation of the modifiers used in types. It corresponds to a syntax role but not a semantic role, not all modifiers are meaningful in every type context.
Prim DotProtoPrimType | |
Optional DotProtoPrimType | |
Repeated DotProtoPrimType | |
NestedRepeated DotProtoPrimType | |
Map DotProtoPrimType DotProtoPrimType |
Instances
Eq DotProtoType Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoType -> DotProtoType -> Bool # (/=) :: DotProtoType -> DotProtoType -> Bool # | |
Show DotProtoType Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoType -> ShowS # show :: DotProtoType -> String # showList :: [DotProtoType] -> ShowS # | |
Arbitrary DotProtoType Source # | |
Defined in Proto3.Suite.DotProto.AST arbitrary :: Gen DotProtoType # shrink :: DotProtoType -> [DotProtoType] # | |
Pretty DotProtoType Source # | |
Defined in Proto3.Suite.DotProto.Rendering pPrintPrec :: PrettyLevel -> Rational -> DotProtoType -> Doc # pPrint :: DotProtoType -> Doc # pPrintList :: PrettyLevel -> [DotProtoType] -> Doc # |
data DotProtoPrimType Source #
Int32 | |
Int64 | |
SInt32 | |
SInt64 | |
UInt32 | |
UInt64 | |
Fixed32 | |
Fixed64 | |
SFixed32 | |
SFixed64 | |
String | |
Bytes | |
Bool | |
Float | |
Double | |
Named DotProtoIdentifier | A named type, referring to another message or enum defined in the same file |
Instances
Eq DotProtoPrimType Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoPrimType -> DotProtoPrimType -> Bool # (/=) :: DotProtoPrimType -> DotProtoPrimType -> Bool # | |
Show DotProtoPrimType Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoPrimType -> ShowS # show :: DotProtoPrimType -> String # showList :: [DotProtoPrimType] -> ShowS # | |
Arbitrary DotProtoPrimType Source # | |
Defined in Proto3.Suite.DotProto.AST arbitrary :: Gen DotProtoPrimType # shrink :: DotProtoPrimType -> [DotProtoPrimType] # | |
Pretty DotProtoPrimType Source # | |
Defined in Proto3.Suite.DotProto.Rendering pPrintPrec :: PrettyLevel -> Rational -> DotProtoPrimType -> Doc # pPrint :: DotProtoPrimType -> Doc # pPrintList :: PrettyLevel -> [DotProtoPrimType] -> Doc # |
data DotProtoValue Source #
Matches the definition of constant
in the proto3 language spec
These are only used as rvalues
Instances
This data structure represents a .proto file The actual source order of protobuf statements isn't meaningful so statements are sorted by type during parsing. A .proto file with more than one package declaration is considered invalid.
data DotProtoMeta Source #
Tracks misc metadata about the AST
DotProtoMeta | |
|
Instances
Eq DotProtoMeta Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoMeta -> DotProtoMeta -> Bool # (/=) :: DotProtoMeta -> DotProtoMeta -> Bool # | |
Show DotProtoMeta Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoMeta -> ShowS # show :: DotProtoMeta -> String # showList :: [DotProtoMeta] -> ShowS # | |
Arbitrary DotProtoMeta Source # | |
Defined in Proto3.Suite.DotProto.AST arbitrary :: Gen DotProtoMeta # shrink :: DotProtoMeta -> [DotProtoMeta] # |
data DotProtoDefinition Source #
Top-level protocol definitions
DotProtoMessage String DotProtoIdentifier [DotProtoMessagePart] | |
DotProtoEnum String DotProtoIdentifier [DotProtoEnumPart] | |
DotProtoService String DotProtoIdentifier [DotProtoServicePart] |
Instances
Eq DotProtoDefinition Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoDefinition -> DotProtoDefinition -> Bool # (/=) :: DotProtoDefinition -> DotProtoDefinition -> Bool # | |
Show DotProtoDefinition Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoDefinition -> ShowS # show :: DotProtoDefinition -> String # showList :: [DotProtoDefinition] -> ShowS # | |
Arbitrary DotProtoDefinition Source # | |
Defined in Proto3.Suite.DotProto.AST |
data DotProtoOption Source #
An option id/value pair, can be attached to many types of statements
Instances
data DotProtoPackageSpec Source #
The namespace declaration
Instances
Eq DotProtoPackageSpec Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: DotProtoPackageSpec -> DotProtoPackageSpec -> Bool # (/=) :: DotProtoPackageSpec -> DotProtoPackageSpec -> Bool # | |
Show DotProtoPackageSpec Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> DotProtoPackageSpec -> ShowS # show :: DotProtoPackageSpec -> String # showList :: [DotProtoPackageSpec] -> ShowS # | |
Arbitrary DotProtoPackageSpec Source # | |
Defined in Proto3.Suite.DotProto.AST | |
Pretty DotProtoPackageSpec Source # | |
Defined in Proto3.Suite.DotProto.Rendering pPrintPrec :: PrettyLevel -> Rational -> DotProtoPackageSpec -> Doc # pPrint :: DotProtoPackageSpec -> Doc # pPrintList :: PrettyLevel -> [DotProtoPackageSpec] -> Doc # |
data DotProtoImportQualifier Source #
Instances
data DotProtoImport Source #
Top-level import declaration
Instances
data DotProtoIdentifier Source #
Instances
newtype PackageName Source #
The name of the package
Instances
Eq PackageName Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: PackageName -> PackageName -> Bool # (/=) :: PackageName -> PackageName -> Bool # | |
Ord PackageName Source # | |
Defined in Proto3.Suite.DotProto.AST compare :: PackageName -> PackageName -> Ordering # (<) :: PackageName -> PackageName -> Bool # (<=) :: PackageName -> PackageName -> Bool # (>) :: PackageName -> PackageName -> Bool # (>=) :: PackageName -> PackageName -> Bool # max :: PackageName -> PackageName -> PackageName # min :: PackageName -> PackageName -> PackageName # | |
Show PackageName Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> PackageName -> ShowS # show :: PackageName -> String # showList :: [PackageName] -> ShowS # | |
IsString PackageName Source # | |
Defined in Proto3.Suite.DotProto.AST fromString :: String -> PackageName # |
The name of some field
newtype MessageName Source #
The name of a message
Instances
Eq MessageName Source # | |
Defined in Proto3.Suite.DotProto.AST (==) :: MessageName -> MessageName -> Bool # (/=) :: MessageName -> MessageName -> Bool # | |
Ord MessageName Source # | |
Defined in Proto3.Suite.DotProto.AST compare :: MessageName -> MessageName -> Ordering # (<) :: MessageName -> MessageName -> Bool # (<=) :: MessageName -> MessageName -> Bool # (>) :: MessageName -> MessageName -> Bool # (>=) :: MessageName -> MessageName -> Bool # max :: MessageName -> MessageName -> MessageName # min :: MessageName -> MessageName -> MessageName # | |
Show MessageName Source # | |
Defined in Proto3.Suite.DotProto.AST showsPrec :: Int -> MessageName -> ShowS # show :: MessageName -> String # showList :: [MessageName] -> ShowS # | |
IsString MessageName Source # | |
Defined in Proto3.Suite.DotProto.AST fromString :: String -> MessageName # |
parseProto :: Path -> String -> Either ParseError DotProto Source #
parseProto mp inp
attempts to parse inp
as a DotProto
. mp
is the
module path to be injected into the AST as part of DotProtoMeta
metadata on
a successful parse.
parseProtoFile :: MonadIO m => Path -> FilePath -> m (Either ParseError DotProto) Source #
parseProtoFile mp fp
reads and parses the .proto file found at fp
. mp
is used downstream during code generation when we need to generate names
which are a function of the source .proto file's filename and its path
relative to some --includeDir
.
typeLikeName :: MonadError CompileError m => String -> m String Source #
fieldLikeName :: String -> String Source #
data RenderingOptions Source #
Options for rendering a .proto
file.
RenderingOptions | |
|
defRenderingOptions :: RenderingOptions Source #
Default rendering options.
defSelectorName :: DotProtoIdentifier -> DotProtoIdentifier -> FieldNumber -> Doc Source #
The default choice of field name for a selector.
defEnumMemberName :: DotProtoIdentifier -> DotProtoIdentifier -> Doc Source #
The default choice of enum member name for an enum
renderDotProto :: RenderingOptions -> DotProto -> Doc Source #
Traverses a DotProto AST and generates a .proto file from it
toProtoFile :: RenderingOptions -> DotProto -> String Source #
Render protobufs metadata as a .proto file stringy
toProtoFileDef :: DotProto -> String Source #
Render protobufs metadata as a .proto file string, using the default rendering options.
packageFromDefs :: String -> [DotProtoDefinition] -> DotProto Source #