packages feed

hydra-kernel-0.16.0: src/main/haskell/Hydra/Core.hs

-- Note: this is an automatically generated file. Do not edit.
-- | Hydra's core data model, consisting of the fundamental hydra.core.Term type and all of its dependencies.

module Hydra.Core where
import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)
import qualified Data.Scientific as Sci
import qualified Data.ByteString as B
import qualified Data.Int as I
import qualified Data.Map as M
import qualified Data.Set as S
-- | A term together with an annotation
data AnnotatedTerm =
  AnnotatedTerm {
    -- | The term being annotated
    annotatedTermBody :: Term,
    -- | The annotation as a single term. By convention this is a map term (Name -> Term) so that multiple independent annotations can coexist, but applications are free to use any term shape.
    annotatedTermAnnotation :: Term}
  deriving (Eq, Ord, Read, Show)
_AnnotatedTerm = Name "hydra.core.AnnotatedTerm"
_AnnotatedTerm_body = Name "body"
_AnnotatedTerm_annotation = Name "annotation"
-- | A type together with an annotation
data AnnotatedType =
  AnnotatedType {
    -- | The type being annotated
    annotatedTypeBody :: Type,
    -- | The annotation as a single term. By convention this is a map term (Name -> Term) so that multiple independent annotations can coexist, but applications are free to use any term shape.
    annotatedTypeAnnotation :: Term}
  deriving (Eq, Ord, Read, Show)
_AnnotatedType = Name "hydra.core.AnnotatedType"
_AnnotatedType_body = Name "body"
_AnnotatedType_annotation = Name "annotation"
-- | A term which applies a function to an argument
data Application =
  Application {
    -- | The left-hand side of the application
    applicationFunction :: Term,
    -- | The right-hand side of the application
    applicationArgument :: Term}
  deriving (Eq, Ord, Read, Show)
_Application = Name "hydra.core.Application"
_Application_function = Name "function"
_Application_argument = Name "argument"
-- | The type-level analog of an application term
data ApplicationType =
  ApplicationType {
    -- | The left-hand side of the application
    applicationTypeFunction :: Type,
    -- | The right-hand side of the application
    applicationTypeArgument :: Type}
  deriving (Eq, Ord, Read, Show)
_ApplicationType = Name "hydra.core.ApplicationType"
_ApplicationType_function = Name "function"
_ApplicationType_argument = Name "argument"
-- | A field with an optional type scheme, used to bind variables to terms in a 'let' expression
data Binding =
  Binding {
    -- | The name of the bound variable
    bindingName :: Name,
    -- | The term to which the variable is bound
    bindingTerm :: Term,
    -- | The optional type scheme of the bound term
    bindingTypeScheme :: (Maybe TypeScheme)}
  deriving (Eq, Ord, Read, Show)
_Binding = Name "hydra.core.Binding"
_Binding_name = Name "name"
_Binding_term = Name "term"
_Binding_typeScheme = Name "typeScheme"
-- | A single alternative of a case statement (union elimination): the variant being matched, together with the term that handles it.
data CaseAlternative =
  CaseAlternative {
    -- | The name of the union variant matched by this alternative
    caseAlternativeName :: Name,
    -- | The handler applied to the matched variant's payload
    caseAlternativeHandler :: Term}
  deriving (Eq, Ord, Read, Show)
_CaseAlternative = Name "hydra.core.CaseAlternative"
_CaseAlternative_name = Name "name"
_CaseAlternative_handler = Name "handler"
-- | A union elimination; a case statement
data CaseStatement =
  CaseStatement {
    -- | The name of the union type
    caseStatementTypeName :: Name,
    -- | An optional default case, used if none of the explicit cases match
    caseStatementDefault :: (Maybe Term),
    -- | A list of case alternatives, one per union variant being handled
    caseStatementCases :: [CaseAlternative]}
  deriving (Eq, Ord, Read, Show)
_CaseStatement = Name "hydra.core.CaseStatement"
_CaseStatement_typeName = Name "typeName"
_CaseStatement_default = Name "default"
_CaseStatement_cases = Name "cases"
-- | A type which provides a choice between a 'left' type and a 'right' type
data EitherType =
  EitherType {
    -- | The 'left' alternative
    eitherTypeLeft :: Type,
    -- | The 'right' alternative
    eitherTypeRight :: Type}
  deriving (Eq, Ord, Read, Show)
_EitherType = Name "hydra.core.EitherType"
_EitherType_left = Name "left"
_EitherType_right = Name "right"
-- | A name/term pair
data Field =
  Field {
    -- | The name of the field
    fieldName :: Name,
    -- | The value of the field
    fieldTerm :: Term}
  deriving (Eq, Ord, Read, Show)
_Field = Name "hydra.core.Field"
_Field_name = Name "name"
_Field_term = Name "term"
-- | A name/type pair
data FieldType =
  FieldType {
    -- | The name of the field
    fieldTypeName :: Name,
    -- | The type of the field
    fieldTypeType :: Type}
  deriving (Eq, Ord, Read, Show)
_FieldType = Name "hydra.core.FieldType"
_FieldType_name = Name "name"
_FieldType_type = Name "type"
-- | A floating-point type
data FloatType =
  -- | A 32-bit floating-point type
  FloatTypeFloat32 |
  -- | A 64-bit floating-point type
  FloatTypeFloat64
  deriving (Eq, Ord, Read, Show)
_FloatType = Name "hydra.core.FloatType"
_FloatType_float32 = Name "float32"
_FloatType_float64 = Name "float64"
-- | A floating-point literal value
data FloatValue =
  -- | A 32-bit floating-point value
  FloatValueFloat32 Float |
  -- | A 64-bit floating-point value
  FloatValueFloat64 Double
  deriving (Eq, Ord, Read, Show)
_FloatValue = Name "hydra.core.FloatValue"
_FloatValue_float32 = Name "float32"
_FloatValue_float64 = Name "float64"
-- | A universally quantified type; the System F equivalent of a type scheme, and the type-level equivalent of a lambda term.
data ForallType =
  ForallType {
    -- | The variable which is bound by the lambda
    forallTypeParameter :: Name,
    -- | The body of the lambda
    forallTypeBody :: Type}
  deriving (Eq, Ord, Read, Show)
_ForallType = Name "hydra.core.ForallType"
_ForallType_parameter = Name "parameter"
_ForallType_body = Name "body"
-- | A function type, also known as an arrow type
data FunctionType =
  FunctionType {
    -- | The domain (input) type of the function
    functionTypeDomain :: Type,
    -- | The codomain (output) type of the function
    functionTypeCodomain :: Type}
  deriving (Eq, Ord, Read, Show)
_FunctionType = Name "hydra.core.FunctionType"
_FunctionType_domain = Name "domain"
_FunctionType_codomain = Name "codomain"
-- | An instance of a union type; i.e. a string-indexed generalization of inl() or inr()
data Injection =
  Injection {
    -- | The name of the union type
    injectionTypeName :: Name,
    -- | The field being injected, including its name and value
    injectionField :: Field}
  deriving (Eq, Ord, Read, Show)
_Injection = Name "hydra.core.Injection"
_Injection_typeName = Name "typeName"
_Injection_field = Name "field"
-- | An integer type
data IntegerType =
  -- | An arbitrary-precision integer type
  IntegerTypeBigint |
  -- | An 8-bit signed integer type
  IntegerTypeInt8 |
  -- | A 16-bit signed integer type
  IntegerTypeInt16 |
  -- | A 32-bit signed integer type
  IntegerTypeInt32 |
  -- | A 64-bit signed integer type
  IntegerTypeInt64 |
  -- | An 8-bit unsigned integer type
  IntegerTypeUint8 |
  -- | A 16-bit unsigned integer type
  IntegerTypeUint16 |
  -- | A 32-bit unsigned integer type
  IntegerTypeUint32 |
  -- | A 64-bit unsigned integer type
  IntegerTypeUint64
  deriving (Eq, Ord, Read, Show)
_IntegerType = Name "hydra.core.IntegerType"
_IntegerType_bigint = Name "bigint"
_IntegerType_int8 = Name "int8"
_IntegerType_int16 = Name "int16"
_IntegerType_int32 = Name "int32"
_IntegerType_int64 = Name "int64"
_IntegerType_uint8 = Name "uint8"
_IntegerType_uint16 = Name "uint16"
_IntegerType_uint32 = Name "uint32"
_IntegerType_uint64 = Name "uint64"
-- | An integer literal value
data IntegerValue =
  -- | An arbitrary-precision integer value
  IntegerValueBigint Integer |
  -- | An 8-bit signed integer value
  IntegerValueInt8 I.Int8 |
  -- | A 16-bit signed integer value (short value)
  IntegerValueInt16 I.Int16 |
  -- | A 32-bit signed integer value (int value)
  IntegerValueInt32 Int |
  -- | A 64-bit signed integer value (long value)
  IntegerValueInt64 I.Int64 |
  -- | An 8-bit unsigned integer value (byte)
  IntegerValueUint8 I.Int16 |
  -- | A 16-bit unsigned integer value
  IntegerValueUint16 Int |
  -- | A 32-bit unsigned integer value (unsigned int)
  IntegerValueUint32 I.Int64 |
  -- | A 64-bit unsigned integer value (unsigned long)
  IntegerValueUint64 Integer
  deriving (Eq, Ord, Read, Show)
_IntegerValue = Name "hydra.core.IntegerValue"
_IntegerValue_bigint = Name "bigint"
_IntegerValue_int8 = Name "int8"
_IntegerValue_int16 = Name "int16"
_IntegerValue_int32 = Name "int32"
_IntegerValue_int64 = Name "int64"
_IntegerValue_uint8 = Name "uint8"
_IntegerValue_uint16 = Name "uint16"
_IntegerValue_uint32 = Name "uint32"
_IntegerValue_uint64 = Name "uint64"
-- | A function abstraction (lambda)
data Lambda =
  Lambda {
    -- | The parameter of the lambda
    lambdaParameter :: Name,
    -- | An optional domain type for the lambda
    lambdaDomain :: (Maybe Type),
    -- | The body of the lambda
    lambdaBody :: Term}
  deriving (Eq, Ord, Read, Show)
_Lambda = Name "hydra.core.Lambda"
_Lambda_parameter = Name "parameter"
_Lambda_domain = Name "domain"
_Lambda_body = Name "body"
-- | A set of (possibly recursive) 'let' bindings together with a body in which they are bound
data Let =
  Let {
    -- | The list of variable bindings
    letBindings :: [Binding],
    -- | The body term in which the variables are bound
    letBody :: Term}
  deriving (Eq, Ord, Read, Show)
_Let = Name "hydra.core.Let"
_Let_bindings = Name "bindings"
_Let_body = Name "body"
-- | A term constant; an instance of a literal type
data Literal =
  -- | A binary literal
  LiteralBinary B.ByteString |
  -- | A boolean literal
  LiteralBoolean Bool |
  -- | An arbitrary-precision decimal literal
  LiteralDecimal Sci.Scientific |
  -- | A floating-point literal
  LiteralFloat FloatValue |
  -- | An integer literal
  LiteralInteger IntegerValue |
  -- | A string literal
  LiteralString String
  deriving (Eq, Ord, Read, Show)
_Literal = Name "hydra.core.Literal"
_Literal_binary = Name "binary"
_Literal_boolean = Name "boolean"
_Literal_decimal = Name "decimal"
_Literal_float = Name "float"
_Literal_integer = Name "integer"
_Literal_string = Name "string"
-- | Any of a fixed set of literal types, also called atomic types, base types, primitive types, or type constants
data LiteralType =
  -- | The type of a binary (byte string) value
  LiteralTypeBinary |
  -- | The type of a boolean (true/false) value
  LiteralTypeBoolean |
  -- | The type of an arbitrary-precision decimal value
  LiteralTypeDecimal |
  -- | The type of a floating-point value
  LiteralTypeFloat FloatType |
  -- | The type of an integer value
  LiteralTypeInteger IntegerType |
  -- | The type of a string value
  LiteralTypeString
  deriving (Eq, Ord, Read, Show)
_LiteralType = Name "hydra.core.LiteralType"
_LiteralType_binary = Name "binary"
_LiteralType_boolean = Name "boolean"
_LiteralType_decimal = Name "decimal"
_LiteralType_float = Name "float"
_LiteralType_integer = Name "integer"
_LiteralType_string = Name "string"
-- | A map type
data MapType =
  MapType {
    -- | The type of keys in the map
    mapTypeKeys :: Type,
    -- | The type of values in the map
    mapTypeValues :: Type}
  deriving (Eq, Ord, Read, Show)
_MapType = Name "hydra.core.MapType"
_MapType_keys = Name "keys"
_MapType_values = Name "values"
-- | A unique identifier in some context; a string-valued key
newtype Name =
  Name {
    unName :: String}
  deriving (Eq, Ord, Read, Show)
_Name = Name "hydra.core.Name"
-- | A type which pairs a 'first' type and a 'second' type
data PairType =
  PairType {
    -- | The first component of the pair
    pairTypeFirst :: Type,
    -- | The second component of the pair
    pairTypeSecond :: Type}
  deriving (Eq, Ord, Read, Show)
_PairType = Name "hydra.core.PairType"
_PairType_first = Name "first"
_PairType_second = Name "second"
-- | A record elimination; a projection
data Projection =
  Projection {
    -- | The name of the record type
    projectionTypeName :: Name,
    -- | The name of the projected field
    projectionFieldName :: Name}
  deriving (Eq, Ord, Read, Show)
_Projection = Name "hydra.core.Projection"
_Projection_typeName = Name "typeName"
_Projection_fieldName = Name "fieldName"
-- | A record, or labeled tuple; a map of field names to terms
data Record =
  Record {
    -- | The name of the record type
    recordTypeName :: Name,
    -- | The fields of the record, as a list of name/term pairs
    recordFields :: [Field]}
  deriving (Eq, Ord, Read, Show)
_Record = Name "hydra.core.Record"
_Record_typeName = Name "typeName"
_Record_fields = Name "fields"
-- | A data term
data Term =
  -- | A term annotated with metadata
  TermAnnotated AnnotatedTerm |
  -- | A function application
  TermApplication Application |
  -- | A union elimination; a case statement
  TermCases CaseStatement |
  -- | An either value
  TermEither (Either Term Term) |
  -- | An injection; an instance of a union type
  TermInject Injection |
  -- | A function abstraction (lambda)
  TermLambda Lambda |
  -- | A 'let' term, which binds variables to terms
  TermLet Let |
  -- | A list
  TermList [Term] |
  -- | A literal value
  TermLiteral Literal |
  -- | A map of keys to values
  TermMap (M.Map Term Term) |
  -- | An optional value
  TermOptional (Maybe Term) |
  -- | A pair (2-tuple)
  TermPair (Term, Term) |
  -- | A record elimination; a projection
  TermProject Projection |
  -- | A record term
  TermRecord Record |
  -- | A set of values
  TermSet (S.Set Term) |
  -- | A System F type application term
  TermTypeApplication TypeApplicationTerm |
  -- | A System F type abstraction term
  TermTypeLambda TypeLambda |
  -- | A unit value; a term with no value
  TermUnit |
  -- | An unwrap elimination; the inverse of a wrap. Given the name of a wrapper type, unwraps an instance of that type to its underlying body value.
  TermUnwrap Name |
  -- | A variable reference
  TermVariable Name |
  -- | A wrapped term; an instance of a wrapper type (newtype)
  TermWrap WrappedTerm
  deriving (Eq, Ord, Read, Show)
_Term = Name "hydra.core.Term"
_Term_annotated = Name "annotated"
_Term_application = Name "application"
_Term_cases = Name "cases"
_Term_either = Name "either"
_Term_inject = Name "inject"
_Term_lambda = Name "lambda"
_Term_let = Name "let"
_Term_list = Name "list"
_Term_literal = Name "literal"
_Term_map = Name "map"
_Term_optional = Name "optional"
_Term_pair = Name "pair"
_Term_project = Name "project"
_Term_record = Name "record"
_Term_set = Name "set"
_Term_typeApplication = Name "typeApplication"
_Term_typeLambda = Name "typeLambda"
_Term_unit = Name "unit"
_Term_unwrap = Name "unwrap"
_Term_variable = Name "variable"
_Term_wrap = Name "wrap"
-- | A data type
data Type =
  -- | An annotated type
  TypeAnnotated AnnotatedType |
  -- | A type application
  TypeApplication ApplicationType |
  -- | An either (sum) type
  TypeEither EitherType |
  -- | A universally quantified (polymorphic) type
  TypeForall ForallType |
  -- | A function type
  TypeFunction FunctionType |
  -- | A list type
  TypeList Type |
  -- | A literal type
  TypeLiteral LiteralType |
  -- | A map type
  TypeMap MapType |
  -- | An optional type
  TypeOptional Type |
  -- | A pair (2-tuple) type
  TypePair PairType |
  -- | A record type
  TypeRecord [FieldType] |
  -- | A set type
  TypeSet Type |
  -- | A union type with field names
  TypeUnion [FieldType] |
  -- | The unit type — the nullary conjunction; one inhabitant. Dual to `void`.
  TypeUnit |
  -- | A type variable
  TypeVariable Name |
  -- | The void (uninhabited, or bottom) type — the nullary disjunction; zero inhabitants. Dual to `unit`.
  TypeVoid |
  -- | A wrapped type (newtype). There is no corresponding `unwrap` variant at the type level: wrap is the introduction form, and a wrapper type's underlying body type is given by the `wrap` variant's argument.
  TypeWrap Type
  deriving (Eq, Ord, Read, Show)
_Type = Name "hydra.core.Type"
_Type_annotated = Name "annotated"
_Type_application = Name "application"
_Type_either = Name "either"
_Type_forall = Name "forall"
_Type_function = Name "function"
_Type_list = Name "list"
_Type_literal = Name "literal"
_Type_map = Name "map"
_Type_optional = Name "optional"
_Type_pair = Name "pair"
_Type_record = Name "record"
_Type_set = Name "set"
_Type_union = Name "union"
_Type_unit = Name "unit"
_Type_variable = Name "variable"
_Type_void = Name "void"
_Type_wrap = Name "wrap"
-- | A term applied to a type; a type application.
data TypeApplicationTerm =
  TypeApplicationTerm {
    -- | The term being applied to a type
    typeApplicationTermBody :: Term,
    -- | The type argument
    typeApplicationTermType :: Type}
  deriving (Eq, Ord, Read, Show)
_TypeApplicationTerm = Name "hydra.core.TypeApplicationTerm"
_TypeApplicationTerm_body = Name "body"
_TypeApplicationTerm_type = Name "type"
-- | A type class constraint on a type variable. Currently has only one variant, but designed to be forward-compatible with multi-parameter type classes and constraints on type expressions.
data TypeClassConstraint =
  -- | A simple type class constraint, naming a single type class
  TypeClassConstraintSimple Name
  deriving (Eq, Ord, Read, Show)
_TypeClassConstraint = Name "hydra.core.TypeClassConstraint"
_TypeClassConstraint_simple = Name "simple"
-- | A System F type abstraction term
data TypeLambda =
  TypeLambda {
    -- | The type variable introduced by the abstraction
    typeLambdaParameter :: Name,
    -- | The body of the abstraction
    typeLambdaBody :: Term}
  deriving (Eq, Ord, Read, Show)
_TypeLambda = Name "hydra.core.TypeLambda"
_TypeLambda_parameter = Name "parameter"
_TypeLambda_body = Name "body"
-- | A type expression together with free type variables occurring in the expression
data TypeScheme =
  TypeScheme {
    -- | The free type variables
    typeSchemeVariables :: [Name],
    -- | The type expression
    typeSchemeBody :: Type,
    -- | Optional constraints on type variables, including typeclass constraints. The map keys are type variable names.
    typeSchemeConstraints :: (Maybe (M.Map Name TypeVariableConstraints))}
  deriving (Eq, Ord, Read, Show)
_TypeScheme = Name "hydra.core.TypeScheme"
_TypeScheme_variables = Name "variables"
_TypeScheme_body = Name "body"
_TypeScheme_constraints = Name "constraints"
-- | Constraints associated with a type variable, including typeclass constraints
data TypeVariableConstraints =
  TypeVariableConstraints {
    -- | The typeclass constraints on this type variable
    typeVariableConstraintsClasses :: [TypeClassConstraint]}
  deriving (Eq, Ord, Read, Show)
_TypeVariableConstraints = Name "hydra.core.TypeVariableConstraints"
_TypeVariableConstraints_classes = Name "classes"
-- | A term wrapped in a type name
data WrappedTerm =
  WrappedTerm {
    -- | The name of the wrapper type
    wrappedTermTypeName :: Name,
    -- | The wrapped term
    wrappedTermBody :: Term}
  deriving (Eq, Ord, Read, Show)
_WrappedTerm = Name "hydra.core.WrappedTerm"
_WrappedTerm_typeName = Name "typeName"
_WrappedTerm_body = Name "body"