Copyright | (c) Abhinav Gupta 2015 |
---|---|
License | BSD3 |
Maintainer | Abhinav Gupta <mail@abhinavg.net> |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
This module defines types that compose a Thrift IDL file.
- data Program srcAnnot = Program {
- programHeaders :: [Header]
- programDefinitions :: [Definition srcAnnot]
- data Header
- = Include {
- includePath :: Text
- | Namespace { }
- = Include {
- data Definition srcAnnot
- = ConstDefinition {
- constType :: FieldType
- constName :: Text
- constValue :: ConstValue
- constDocstring :: Docstring
- constSrcAnnot :: srcAnnot
- | TypeDefinition {
- typeDefinition :: Type srcAnnot
- typeAnnotations :: [TypeAnnotation]
- | ServiceDefinition {
- serviceName :: Text
- serviceExtends :: Maybe Text
- serviceFunctions :: [Function srcAnnot]
- serviceAnnotations :: [TypeAnnotation]
- serviceDocstring :: Docstring
- serviceSrcAnnot :: srcAnnot
- = ConstDefinition {
- data Type srcAnnot
- = Typedef {
- typedefType :: FieldType
- typedefName :: Text
- typedefDocstring :: Docstring
- typedefSrcAnnot :: srcAnnot
- | Enum {
- enumName :: Text
- enumValues :: [EnumDef srcAnnot]
- enumDocstring :: Docstring
- enumSrcAnnot :: srcAnnot
- | Struct {
- structName :: Text
- structFields :: [Field srcAnnot]
- structDocstring :: Docstring
- structSrcAnnot :: srcAnnot
- | Union {
- unionName :: Text
- unionFields :: [Field srcAnnot]
- unionDocstring :: Docstring
- unionSrcAnnot :: srcAnnot
- | Exception {
- exceptionName :: Text
- exceptionFields :: [Field srcAnnot]
- exceptionDocstring :: Docstring
- exceptionSrcAnnot :: srcAnnot
- | Senum {
- senumName :: Text
- senumValues :: [Text]
- senumDocstring :: Docstring
- senumSrcAnnot :: srcAnnot
- = Typedef {
- data FieldRequiredness
- data Field srcAnnot = Field {}
- data EnumDef srcAnnot = EnumDef {
- enumDefName :: Text
- enumDefValue :: Maybe Integer
- enumDefAnnotations :: [TypeAnnotation]
- enumDefDocstring :: Docstring
- enumDefSrcAnnot :: srcAnnot
- data ConstValue
- data FieldType
- = DefinedType Text
- | StringType [TypeAnnotation]
- | BinaryType [TypeAnnotation]
- | SListType [TypeAnnotation]
- | BoolType [TypeAnnotation]
- | ByteType [TypeAnnotation]
- | I16Type [TypeAnnotation]
- | I32Type [TypeAnnotation]
- | I64Type [TypeAnnotation]
- | DoubleType [TypeAnnotation]
- | MapType FieldType FieldType [TypeAnnotation]
- | SetType FieldType [TypeAnnotation]
- | ListType FieldType [TypeAnnotation]
- data Function srcAnnot = Function {
- functionOneWay :: Bool
- functionReturnType :: Maybe FieldType
- functionName :: Text
- functionParameters :: [Field srcAnnot]
- functionExceptions :: Maybe [Field srcAnnot]
- functionAnnotations :: [TypeAnnotation]
- functionDocstring :: Docstring
- functionSrcAnnot :: srcAnnot
- data TypeAnnotation = TypeAnnotation {}
- type Docstring = Maybe Text
Documentation
A program represents a single Thrift document.
Program | |
|
Headers for a program.
Include | The IDL includes another Thrift file. include "common.thrift" typedef common.Foo Bar |
| |
Namespace | Namespace directives allows control of the namespace or package name used by the generated code for certain languages. namespace py my_service.generated |
|
data Definition srcAnnot Source
A definition either consists of new constants, new types, or new services.
ConstDefinition | A declared constant. const i32 code = 1; |
| |
TypeDefinition | A declared type. |
| |
ServiceDefinition | A service definition. service MyService { // ... } |
|
Eq srcAnnot => Eq (Definition srcAnnot) Source | |
Data srcAnnot => Data (Definition srcAnnot) Source | |
Ord srcAnnot => Ord (Definition srcAnnot) Source | |
Show srcAnnot => Show (Definition srcAnnot) Source | |
Generic (Definition srcAnnot) Source | |
type Rep (Definition srcAnnot) Source |
Defines the various types that can be declared in Thrift.
Typedef | A typedef is just an alias for another type. typedef common.Foo Bar |
| |
Enum | Enums are sets of named integer values. enum Role { User = 1, Admin = 2 } |
| |
Struct | A struct definition struct User { 1: Role role = Role.User; } |
| |
Union | A union of other types. union Value { 1: string stringValue; 2: i32 intValue; } |
| |
Exception | Exception types. exception UserDoesNotExist { 1: optional string message 2: required string username } |
| |
Senum | An string-only enum. These are a deprecated feature of Thrift and shouldn't be used. |
|
data FieldRequiredness Source
Whether a field is required or optional.
A field inside a struct, exception, or function parameters list.
Field | |
|
A named value inside an enum.
EnumDef | |
|
data ConstValue Source
A constant literal value in the IDL. Only a few basic types, lists, and maps can be presented in Thrift files as literals.
Constants are used for IDL-level constants and default values for fields.
ConstInt Integer | An integer. |
ConstFloat Double | A float. |
ConstLiteral Text | A literal string. |
ConstIdentifier Text | A literal identifier. |
ConstList [ConstValue] | A literal list containing other constant values. |
ConstMap [(ConstValue, ConstValue)] | A literal list containing other constant values.
|
A reference to a type.
DefinedType Text | A custom defined type referred to by name. |
StringType [TypeAnnotation] |
|
BinaryType [TypeAnnotation] |
|
SListType [TypeAnnotation] |
|
BoolType [TypeAnnotation] |
|
ByteType [TypeAnnotation] |
|
I16Type [TypeAnnotation] |
|
I32Type [TypeAnnotation] |
|
I64Type [TypeAnnotation] |
|
DoubleType [TypeAnnotation] |
|
MapType FieldType FieldType [TypeAnnotation] |
|
SetType FieldType [TypeAnnotation] |
|
ListType FieldType [TypeAnnotation] |
|
A function defined inside a service.
Function | |
|
data TypeAnnotation Source
Type annoations may be added in various places in the form,
("foo" = "bar", "baz" = "qux")
These do not usually affect code generation but allow for custom logic if writing your own code generator.
TypeAnnotation | |
|