| Copyright | (c) Abhinav Gupta 2015 |
|---|---|
| License | BSD3 |
| Maintainer | Abhinav Gupta <mail@abhinavg.net> |
| Stability | experimental |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Language.Thrift.Types
Description
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.
Constructors
| Program | |
Fields
| |
Headers for a program.
Constructors
| Include | The IDL includes another Thrift file. include "common.thrift" typedef common.Foo Bar |
Fields
| |
| Namespace | Namespace directives allows control of the namespace or package name used by the generated code for certain languages. namespace py my_service.generated |
Fields
| |
data Definition srcAnnot Source
A definition either consists of new constants, new types, or new services.
Constructors
| ConstDefinition | A declared constant. const i32 code = 1; |
Fields
| |
| TypeDefinition | A declared type. |
Fields
| |
| ServiceDefinition | A service definition. service MyService {
// ...
} |
Fields
| |
Instances
| 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.
Constructors
| Typedef | A typedef is just an alias for another type. typedef common.Foo Bar |
Fields
| |
| Enum | Enums are sets of named integer values. enum Role {
User = 1, Admin = 2
} |
Fields
| |
| Struct | A struct definition struct User {
1: Role role = Role.User;
} |
Fields
| |
| Union | A union of other types. union Value {
1: string stringValue;
2: i32 intValue;
} |
Fields
| |
| Exception | Exception types. exception UserDoesNotExist {
1: optional string message
2: required string username
} |
Fields
| |
| Senum | An string-only enum. These are a deprecated feature of Thrift and shouldn't be used. |
Fields
| |
data FieldRequiredness Source
Whether a field is required or optional.
A field inside a struct, exception, or function parameters list.
Constructors
| Field | |
Fields
| |
A named value inside an enum.
Constructors
| EnumDef | |
Fields
| |
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.
Constructors
| 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.
|
Instances
A reference to a type.
Constructors
| 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.
Constructors
| Function | |
Fields
| |
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.
Constructors
| TypeAnnotation | |
Fields
| |