hydra-kernel-0.17.7: src/main/haskell/Hydra/Paths.hs
-- Note: this is an automatically generated file. Do not edit.
-- | Subterm and subtype access, and the term/type graph view of a graph
module Hydra.Paths where
import qualified Hydra.Core as Core
import Prelude hiding (Enum, Ordering, decodeFloat, encodeFloat, fail, lines, map, pure, sum, unlines)
import qualified Data.Scientific as Sci
import Data.Void
import qualified Data.Map as M
-- | A reference to a lambda-bound variable: the node introducing it is the binding lambda
data LambdaVariableReference =
LambdaVariableReference {
-- | The name of the lambda-bound variable
lambdaVariableReferenceVariable :: Core.Name,
-- | The id of the node at the binding lambda
lambdaVariableReferenceBoundByNode :: TermNodeId,
-- | The type of the variable
lambdaVariableReferenceType :: Core.Type}
deriving (Eq, Ord, Read, Show)
_LambdaVariableReference = Core.Name "hydra.paths.LambdaVariableReference"
_LambdaVariableReference_variable = Core.Name "variable"
_LambdaVariableReference_boundByNode = Core.Name "boundByNode"
_LambdaVariableReference_type = Core.Name "type"
-- | A reference to a let-bound variable: the node introducing it is the bound term
data LetVariableReference =
LetVariableReference {
-- | The name of the let-bound variable
letVariableReferenceVariable :: Core.Name,
-- | The id of the node at the bound term
letVariableReferenceBindingNode :: TermNodeId,
-- | The type of the variable
letVariableReferenceType :: Core.Type}
deriving (Eq, Ord, Read, Show)
_LetVariableReference = Core.Name "hydra.paths.LetVariableReference"
_LetVariableReference_variable = Core.Name "variable"
_LetVariableReference_bindingNode = Core.Name "bindingNode"
_LetVariableReference_type = Core.Name "type"
-- | A reference to a named type of the schema (analogous to a let-bound variable)
data NominalTypeReference =
NominalTypeReference {
-- | The name of the referenced schema type
nominalTypeReferenceName :: Core.Name}
deriving (Eq, Ord, Read, Show)
_NominalTypeReference = Core.Name "hydra.paths.NominalTypeReference"
_NominalTypeReference_name = Core.Name "name"
-- | A reference to a primitive function
data PrimitiveReference =
PrimitiveReference {
-- | The name of the primitive
primitiveReferenceName :: Core.Name,
-- | The type of the primitive
primitiveReferenceType :: Core.Type}
deriving (Eq, Ord, Read, Show)
_PrimitiveReference = Core.Name "hydra.paths.PrimitiveReference"
_PrimitiveReference_name = Core.Name "name"
_PrimitiveReference_type = Core.Name "type"
-- | An outgoing link to an immediate subterm, carried inline as a child node
data SubtermLink =
SubtermLink {
-- | The step by which the child subterm is reached
subtermLinkStep :: SubtermStep,
-- | The child node (inline; the structure is a tree)
subtermLinkChild :: TermNode}
deriving (Eq, Ord, Read, Show)
_SubtermLink = Core.Name "hydra.paths.SubtermLink"
_SubtermLink_step = Core.Name "step"
_SubtermLink_child = Core.Name "child"
-- | A sequence of subterm steps forming a path through a term, root first
newtype SubtermPath =
SubtermPath {
unSubtermPath :: [SubtermStep]}
deriving (Eq, Ord, Read, Show)
_SubtermPath = Core.Name "hydra.paths.SubtermPath"
-- | A function which maps from a term to a particular immediate subterm
data SubtermStep =
-- | Access the annotation of an annotated term
SubtermStepAnnotatedAnnotation |
-- | Access the body of an annotated term
SubtermStepAnnotatedBody |
-- | Access the argument of an application term
SubtermStepApplicationArgument |
-- | Access the function of an application term
SubtermStepApplicationFunction |
-- | Access the handler of a specific case of a case statement by field name
SubtermStepCasesCase Core.Name |
-- | Access the default case of a case statement
SubtermStepCasesDefault |
-- | Access the left term of an either value
SubtermStepEitherLeft |
-- | Access the right term of an either value
SubtermStepEitherRight |
-- | Access the injected term of a union injection by field name
SubtermStepInjectField Core.Name |
-- | Access the body of a lambda term
SubtermStepLambdaBody |
-- | Access a specific binding in a let term by variable name
SubtermStepLetBinding Core.Name |
-- | Access the body of a let term
SubtermStepLetBody |
-- | Access an element of a list by index
SubtermStepListElement Int |
-- | Access the map entry at the given index as a pair (k, v). Accessing this step constructs the pair; the entry is not itself a subterm occurrence, though its key and value components are, reached via pairFirst/pairSecond. Entry indexes follow the total order on serializable terms.
SubtermStepMapEntry Int |
-- | Access the term inside a given (present) optional value
SubtermStepOptionalGiven |
-- | Access the first term of a pair
SubtermStepPairFirst |
-- | Access the second term of a pair
SubtermStepPairSecond |
-- | Access a field of a record by field name
SubtermStepRecordField Core.Name |
-- | Access an element of a set by index
SubtermStepSetElement Int |
-- | Access the body of a type application term
SubtermStepTypeApplicationBody |
-- | Access the body of a type lambda term
SubtermStepTypeLambdaBody |
-- | Access the body of a wrapped term
SubtermStepWrapBody
deriving (Eq, Ord, Read, Show)
_SubtermStep = Core.Name "hydra.paths.SubtermStep"
_SubtermStep_annotatedAnnotation = Core.Name "annotatedAnnotation"
_SubtermStep_annotatedBody = Core.Name "annotatedBody"
_SubtermStep_applicationArgument = Core.Name "applicationArgument"
_SubtermStep_applicationFunction = Core.Name "applicationFunction"
_SubtermStep_casesCase = Core.Name "casesCase"
_SubtermStep_casesDefault = Core.Name "casesDefault"
_SubtermStep_eitherLeft = Core.Name "eitherLeft"
_SubtermStep_eitherRight = Core.Name "eitherRight"
_SubtermStep_injectField = Core.Name "injectField"
_SubtermStep_lambdaBody = Core.Name "lambdaBody"
_SubtermStep_letBinding = Core.Name "letBinding"
_SubtermStep_letBody = Core.Name "letBody"
_SubtermStep_listElement = Core.Name "listElement"
_SubtermStep_mapEntry = Core.Name "mapEntry"
_SubtermStep_optionalGiven = Core.Name "optionalGiven"
_SubtermStep_pairFirst = Core.Name "pairFirst"
_SubtermStep_pairSecond = Core.Name "pairSecond"
_SubtermStep_recordField = Core.Name "recordField"
_SubtermStep_setElement = Core.Name "setElement"
_SubtermStep_typeApplicationBody = Core.Name "typeApplicationBody"
_SubtermStep_typeLambdaBody = Core.Name "typeLambdaBody"
_SubtermStep_wrapBody = Core.Name "wrapBody"
-- | An outgoing link to an immediate subtype, carried inline as a child node
data SubtypeLink =
SubtypeLink {
-- | The step by which the child subtype is reached
subtypeLinkStep :: SubtypeStep,
-- | The child node (inline; the structure is a tree)
subtypeLinkChild :: TypeNode}
deriving (Eq, Ord, Read, Show)
_SubtypeLink = Core.Name "hydra.paths.SubtypeLink"
_SubtypeLink_step = Core.Name "step"
_SubtypeLink_child = Core.Name "child"
-- | A sequence of subtype steps forming a path through a type, root first
newtype SubtypePath =
SubtypePath {
unSubtypePath :: [SubtypeStep]}
deriving (Eq, Ord, Read, Show)
_SubtypePath = Core.Name "hydra.paths.SubtypePath"
-- | A function which maps from a type to a particular immediate subtype
data SubtypeStep =
-- | Access the body of an annotated type (the annotation is a term; there is no step for it)
SubtypeStepAnnotatedBody |
-- | Access the argument of an application type
SubtypeStepApplicationArgument |
-- | Access the function of an application type
SubtypeStepApplicationFunction |
-- | Access the value type of an effect type
SubtypeStepEffectValue |
-- | Access the left type of an either type
SubtypeStepEitherLeft |
-- | Access the right type of an either type
SubtypeStepEitherRight |
-- | Access the body of a universally quantified type
SubtypeStepForallBody |
-- | Access the codomain type of a function type
SubtypeStepFunctionCodomain |
-- | Access the domain type of a function type
SubtypeStepFunctionDomain |
-- | Access the element type of a list type
SubtypeStepListElement |
-- | Access the key type of a map type
SubtypeStepMapKeys |
-- | Access the value type of a map type
SubtypeStepMapValues |
-- | Access the element type of an optional type
SubtypeStepOptionalElement |
-- | Access the first type of a pair type
SubtypeStepPairFirst |
-- | Access the second type of a pair type
SubtypeStepPairSecond |
-- | Access a field type of a record type by field name
SubtypeStepRecordField Core.Name |
-- | Access the element type of a set type
SubtypeStepSetElement |
-- | Access a field type of a union type by field name
SubtypeStepUnionField Core.Name |
-- | Access the body type of a wrapped type
SubtypeStepWrapBody
deriving (Eq, Ord, Read, Show)
_SubtypeStep = Core.Name "hydra.paths.SubtypeStep"
_SubtypeStep_annotatedBody = Core.Name "annotatedBody"
_SubtypeStep_applicationArgument = Core.Name "applicationArgument"
_SubtypeStep_applicationFunction = Core.Name "applicationFunction"
_SubtypeStep_effectValue = Core.Name "effectValue"
_SubtypeStep_eitherLeft = Core.Name "eitherLeft"
_SubtypeStep_eitherRight = Core.Name "eitherRight"
_SubtypeStep_forallBody = Core.Name "forallBody"
_SubtypeStep_functionCodomain = Core.Name "functionCodomain"
_SubtypeStep_functionDomain = Core.Name "functionDomain"
_SubtypeStep_listElement = Core.Name "listElement"
_SubtypeStep_mapKeys = Core.Name "mapKeys"
_SubtypeStep_mapValues = Core.Name "mapValues"
_SubtypeStep_optionalElement = Core.Name "optionalElement"
_SubtypeStep_pairFirst = Core.Name "pairFirst"
_SubtypeStep_pairSecond = Core.Name "pairSecond"
_SubtypeStep_recordField = Core.Name "recordField"
_SubtypeStep_setElement = Core.Name "setElement"
_SubtypeStep_unionField = Core.Name "unionField"
_SubtypeStep_wrapBody = Core.Name "wrapBody"
-- | A non-term constituent of this node's term, with its value
data TermAttributeLink =
-- | The name of the union type eliminated by a case statement
TermAttributeLinkCasesTypeName Core.Name |
-- | The name of the union type of an injection
TermAttributeLinkInjectTypeName Core.Name |
-- | The (given) domain type of a lambda
TermAttributeLinkLambdaDomainGiven Core.Type |
-- | The parameter name of a lambda
TermAttributeLinkLambdaParameter Core.Name |
-- | The name of a let binding together with its (given) type scheme
TermAttributeLinkLetBindingTypeSchemeGiven (Core.Name, Core.TypeScheme) |
-- | The literal value of a literal term (a leaf)
TermAttributeLinkLiteral Core.Literal |
-- | The name of the field projected by a projection
TermAttributeLinkProjectFieldName Core.Name |
-- | The name of the record type of a projection
TermAttributeLinkProjectTypeName Core.Name |
-- | The name of the record type of a record term
TermAttributeLinkRecordTypeName Core.Name |
-- | The type argument of a type application term
TermAttributeLinkTypeApplicationType Core.Type |
-- | The type-variable parameter of a type lambda term
TermAttributeLinkTypeLambdaParameter Core.Name |
-- | The name of the wrapper type eliminated by an unwrap
TermAttributeLinkUnwrapTypeName Core.Name |
-- | The name of the wrapper type of a wrapped term
TermAttributeLinkWrapTypeName Core.Name
deriving (Eq, Ord, Read, Show)
_TermAttributeLink = Core.Name "hydra.paths.TermAttributeLink"
_TermAttributeLink_casesTypeName = Core.Name "casesTypeName"
_TermAttributeLink_injectTypeName = Core.Name "injectTypeName"
_TermAttributeLink_lambdaDomainGiven = Core.Name "lambdaDomainGiven"
_TermAttributeLink_lambdaParameter = Core.Name "lambdaParameter"
_TermAttributeLink_letBindingTypeSchemeGiven = Core.Name "letBindingTypeSchemeGiven"
_TermAttributeLink_literal = Core.Name "literal"
_TermAttributeLink_projectFieldName = Core.Name "projectFieldName"
_TermAttributeLink_projectTypeName = Core.Name "projectTypeName"
_TermAttributeLink_recordTypeName = Core.Name "recordTypeName"
_TermAttributeLink_typeApplicationType = Core.Name "typeApplicationType"
_TermAttributeLink_typeLambdaParameter = Core.Name "typeLambdaParameter"
_TermAttributeLink_unwrapTypeName = Core.Name "unwrapTypeName"
_TermAttributeLink_wrapTypeName = Core.Name "wrapTypeName"
-- | A typed graph as a term graph: one root node per binding of the graph
data TermGraph =
TermGraph {
-- | The root nodes, keyed by binding name
termGraphRoots :: (M.Map Core.Name TermNode)}
deriving (Eq, Ord, Read, Show)
_TermGraph = Core.Name "hydra.paths.TermGraph"
_TermGraph_roots = Core.Name "roots"
-- | An outgoing link of a term node: an inline subterm, a variable occurrence, or a non-term attribute
data TermLink =
-- | A non-term constituent of this node's term
TermLinkAttribute TermAttributeLink |
-- | A variable or primitive occurrence
TermLinkReference TermReferenceLink |
-- | An immediate subterm, carried inline
TermLinkSubterm SubtermLink
deriving (Eq, Ord, Read, Show)
_TermLink = Core.Name "hydra.paths.TermLink"
_TermLink_attribute = Core.Name "attribute"
_TermLink_reference = Core.Name "reference"
_TermLink_subterm = Core.Name "subterm"
-- | A node in a term graph: a subterm as written, its type, and its outgoing links
data TermNode =
TermNode {
-- | The subterm as written
termNodeTerm :: Core.Term,
-- | The subterm's type (a binding's forall type at roots), via hydra.checking
termNodeType :: Core.Type,
-- | The outgoing links of the node
termNodeLinks :: [TermLink]}
deriving (Eq, Ord, Read, Show)
_TermNode = Core.Name "hydra.paths.TermNode"
_TermNode_term = Core.Name "term"
_TermNode_type = Core.Name "type"
_TermNode_links = Core.Name "links"
-- | The id of a term-graph node: a root binding name plus a subterm path from that root. A root node's id has an empty path. A letBinding step appears only for an actual nested let inside a binding's term, never as a leading pseudo-step.
data TermNodeId =
TermNodeId {
-- | The name of the root binding
termNodeIdRoot :: Core.Name,
-- | The subterm path from the root
termNodeIdPath :: SubtermPath}
deriving (Eq, Ord, Read, Show)
_TermNodeId = Core.Name "hydra.paths.TermNodeId"
_TermNodeId_root = Core.Name "root"
_TermNodeId_path = Core.Name "path"
-- | The target of a variable or primitive occurrence
data TermReference =
-- | A reference to a lambda-bound variable
TermReferenceLambda LambdaVariableReference |
-- | A reference to a let-bound variable
TermReferenceLet LetVariableReference |
-- | A reference to a primitive function
TermReferencePrimitive PrimitiveReference
deriving (Eq, Ord, Read, Show)
_TermReference = Core.Name "hydra.paths.TermReference"
_TermReference_lambda = Core.Name "lambda"
_TermReference_let = Core.Name "let"
_TermReference_primitive = Core.Name "primitive"
-- | An outgoing link to a variable or primitive occurrence
data TermReferenceLink =
TermReferenceLink {
-- | The step by which the occurrence is reached
termReferenceLinkStep :: SubtermStep,
-- | The referenced binding, lambda parameter, or primitive
termReferenceLinkTarget :: TermReference}
deriving (Eq, Ord, Read, Show)
_TermReferenceLink = Core.Name "hydra.paths.TermReferenceLink"
_TermReferenceLink_step = Core.Name "step"
_TermReferenceLink_target = Core.Name "target"
-- | A non-type constituent of this node's type, with its value
data TypeAttributeLink =
-- | The annotation of an annotated type (a term; not descended into)
TypeAttributeLinkAnnotatedAnnotation Core.Term |
-- | The type-variable parameter of a universally quantified type
TypeAttributeLinkForallParameter Core.Name |
-- | The literal type of a literal type (a leaf)
TypeAttributeLinkLiteral Core.LiteralType
deriving (Eq, Ord, Read, Show)
_TypeAttributeLink = Core.Name "hydra.paths.TypeAttributeLink"
_TypeAttributeLink_annotatedAnnotation = Core.Name "annotatedAnnotation"
_TypeAttributeLink_forallParameter = Core.Name "forallParameter"
_TypeAttributeLink_literal = Core.Name "literal"
-- | A schema as a type graph: one root node per named type
data TypeGraph =
TypeGraph {
-- | The root nodes, keyed by type name
typeGraphRoots :: (M.Map Core.Name TypeNode)}
deriving (Eq, Ord, Read, Show)
_TypeGraph = Core.Name "hydra.paths.TypeGraph"
_TypeGraph_roots = Core.Name "roots"
-- | An outgoing link of a type node: an inline subtype, a type reference, or a non-type attribute
data TypeLink =
-- | A non-type constituent of this node's type
TypeLinkAttribute TypeAttributeLink |
-- | A named-type or type-variable occurrence
TypeLinkReference TypeReferenceLink |
-- | An immediate subtype, carried inline
TypeLinkSubtype SubtypeLink
deriving (Eq, Ord, Read, Show)
_TypeLink = Core.Name "hydra.paths.TypeLink"
_TypeLink_attribute = Core.Name "attribute"
_TypeLink_reference = Core.Name "reference"
_TypeLink_subtype = Core.Name "subtype"
-- | A node in a type graph: a subtype as written and its outgoing links
data TypeNode =
TypeNode {
-- | The subtype as written (needed for linkless leaves: literal types, unit, void)
typeNodeType :: Core.Type,
-- | The outgoing links of the node
typeNodeLinks :: [TypeLink]}
deriving (Eq, Ord, Read, Show)
_TypeNode = Core.Name "hydra.paths.TypeNode"
_TypeNode_type = Core.Name "type"
_TypeNode_links = Core.Name "links"
-- | The id of a type-graph node: a root type name plus a subtype path from that root. A root node's id has an empty path. There is no enclosing-let analog for schemas.
data TypeNodeId =
TypeNodeId {
-- | The name of the root type
typeNodeIdRoot :: Core.Name,
-- | The subtype path from the root
typeNodeIdPath :: SubtypePath}
deriving (Eq, Ord, Read, Show)
_TypeNodeId = Core.Name "hydra.paths.TypeNodeId"
_TypeNodeId_root = Core.Name "root"
_TypeNodeId_path = Core.Name "path"
-- | The target of a named-type or type-variable occurrence
data TypeReference =
-- | A reference to a named type of the schema
TypeReferenceNominal NominalTypeReference |
-- | A reference to a forall-bound type variable
TypeReferenceVariable TypeVariableReference
deriving (Eq, Ord, Read, Show)
_TypeReference = Core.Name "hydra.paths.TypeReference"
_TypeReference_nominal = Core.Name "nominal"
_TypeReference_variable = Core.Name "variable"
-- | An outgoing link to a named-type or type-variable occurrence
data TypeReferenceLink =
TypeReferenceLink {
-- | The step by which the occurrence is reached
typeReferenceLinkStep :: SubtypeStep,
-- | The referenced named type or type variable
typeReferenceLinkTarget :: TypeReference}
deriving (Eq, Ord, Read, Show)
_TypeReferenceLink = Core.Name "hydra.paths.TypeReferenceLink"
_TypeReferenceLink_step = Core.Name "step"
_TypeReferenceLink_target = Core.Name "target"
-- | A reference to a forall-bound type variable: the node introducing it is the binder
data TypeVariableReference =
TypeVariableReference {
-- | The name of the forall-bound type variable
typeVariableReferenceVariable :: Core.Name,
-- | The id of the node at the binding forall
typeVariableReferenceBoundByNode :: TypeNodeId}
deriving (Eq, Ord, Read, Show)
_TypeVariableReference = Core.Name "hydra.paths.TypeVariableReference"
_TypeVariableReference_variable = Core.Name "variable"
_TypeVariableReference_boundByNode = Core.Name "boundByNode"