hydra-kernel-0.17.6: src/main/haskell/Hydra/Decode/Paths.hs
-- Note: this is an automatically generated file. Do not edit.
-- | Term decoders for hydra.paths
module Hydra.Decode.Paths where
import qualified Hydra.Core as Core
import qualified Hydra.Decode.Core as DecodeCore
import qualified Hydra.Errors as Errors
import qualified Hydra.Extract.Core as ExtractCore
import qualified Hydra.Graph as Graph
import qualified Hydra.Lexical as Lexical
import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers
import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps
import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals
import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings
import qualified Hydra.Paths as Paths
import qualified Hydra.Rewriting as Rewriting
import qualified Hydra.Util as Util
import Prelude hiding (Enum, Ordering, decodeFloat, encodeFloat, fail, lines, map, pure, sum, unlines)
import qualified Data.Scientific as Sci
import Data.Void
-- | Decoder for hydra.paths.SubtermAttribute
subtermAttribute :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtermAttribute
subtermAttribute cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "path" subtermPath fieldMap cx) (\field_path -> Eithers.bind (ExtractCore.requireField "target" termAttribute fieldMap cx) (\field_target -> Right (Paths.SubtermAttribute {
Paths.subtermAttributePath = field_path,
Paths.subtermAttributeTarget = field_target}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtermAttribute")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtermEdge
subtermEdge :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtermEdge
subtermEdge cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "path" subtermPath fieldMap cx) (\field_path -> Eithers.bind (ExtractCore.requireField "target" DecodeCore.name fieldMap cx) (\field_target -> Right (Paths.SubtermEdge {
Paths.subtermEdgePath = field_path,
Paths.subtermEdgeTarget = field_target}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtermEdge")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtermGraph
subtermGraph :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtermGraph
subtermGraph cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "nodes" (ExtractCore.decodeList subtermNode) fieldMap cx) (\field_nodes -> Right (Paths.SubtermGraph {
Paths.subtermGraphNodes = field_nodes})))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtermGraph")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtermLink
subtermLink :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtermLink
subtermLink cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermInject v0 ->
let field = Core.injectionField v0
fname = Core.fieldName field
fterm = Core.fieldTerm field
variantMap =
Maps.fromList [
(Core.Name "edge", (\input -> Eithers.map (\t -> Paths.SubtermLinkEdge t) (subtermEdge cx input))),
(Core.Name "property", (\input -> Eithers.map (\t -> Paths.SubtermLinkProperty t) (subtermProperty cx input))),
(Core.Name "attribute", (\input -> Eithers.map (\t -> Paths.SubtermLinkAttribute t) (subtermAttribute cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Core.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtermNode
subtermNode :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtermNode
subtermNode cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "name" DecodeCore.name fieldMap cx) (\field_name -> Eithers.bind (ExtractCore.requireField "type" DecodeCore.typeScheme fieldMap cx) (\field_type -> Eithers.bind (ExtractCore.requireField "links" (ExtractCore.decodeList subtermLink) fieldMap cx) (\field_links -> Right (Paths.SubtermNode {
Paths.subtermNodeName = field_name,
Paths.subtermNodeType = field_type,
Paths.subtermNodeLinks = field_links})))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtermNode")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtermPath
subtermPath :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtermPath
subtermPath cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermWrap v0 -> Eithers.map (\b -> Paths.SubtermPath b) (ExtractCore.decodeList subtermStep cx (Core.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtermProperty
subtermProperty :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtermProperty
subtermProperty cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "path" subtermPath fieldMap cx) (\field_path -> Eithers.bind (ExtractCore.requireField "target" DecodeCore.term fieldMap cx) (\field_target -> Right (Paths.SubtermProperty {
Paths.subtermPropertyPath = field_path,
Paths.subtermPropertyTarget = field_target}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtermProperty")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtermStep
subtermStep :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtermStep
subtermStep cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermInject v0 ->
let field = Core.injectionField v0
fname = Core.fieldName field
fterm = Core.fieldTerm field
variantMap =
Maps.fromList [
(
Core.Name "annotatedAnnotation",
(\input -> Eithers.map (\t -> Paths.SubtermStepAnnotatedAnnotation) (ExtractCore.decodeUnit cx input))),
(
Core.Name "annotatedBody",
(\input -> Eithers.map (\t -> Paths.SubtermStepAnnotatedBody) (ExtractCore.decodeUnit cx input))),
(
Core.Name "applicationArgument",
(\input -> Eithers.map (\t -> Paths.SubtermStepApplicationArgument) (ExtractCore.decodeUnit cx input))),
(
Core.Name "applicationFunction",
(\input -> Eithers.map (\t -> Paths.SubtermStepApplicationFunction) (ExtractCore.decodeUnit cx input))),
(Core.Name "casesCase", (\input -> Eithers.map (\t -> Paths.SubtermStepCasesCase t) (DecodeCore.name cx input))),
(
Core.Name "casesDefault",
(\input -> Eithers.map (\t -> Paths.SubtermStepCasesDefault) (ExtractCore.decodeUnit cx input))),
(Core.Name "eitherLeft", (\input -> Eithers.map (\t -> Paths.SubtermStepEitherLeft) (ExtractCore.decodeUnit cx input))),
(Core.Name "eitherRight", (\input -> Eithers.map (\t -> Paths.SubtermStepEitherRight) (ExtractCore.decodeUnit cx input))),
(Core.Name "injectField", (\input -> Eithers.map (\t -> Paths.SubtermStepInjectField t) (DecodeCore.name cx input))),
(Core.Name "lambdaBody", (\input -> Eithers.map (\t -> Paths.SubtermStepLambdaBody) (ExtractCore.decodeUnit cx input))),
(Core.Name "letBinding", (\input -> Eithers.map (\t -> Paths.SubtermStepLetBinding t) (DecodeCore.name cx input))),
(Core.Name "letBody", (\input -> Eithers.map (\t -> Paths.SubtermStepLetBody) (ExtractCore.decodeUnit cx input))),
(
Core.Name "listElement",
(\input -> Eithers.map (\t -> Paths.SubtermStepListElement t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Core.TermLiteral v1 -> case v1 of
Core.LiteralInteger v2 -> case v2 of
Core.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractCore.stripWithDecodingError cx input)))),
(
Core.Name "mapKey",
(\input -> Eithers.map (\t -> Paths.SubtermStepMapKey t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Core.TermLiteral v1 -> case v1 of
Core.LiteralInteger v2 -> case v2 of
Core.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractCore.stripWithDecodingError cx input)))),
(
Core.Name "mapValue",
(\input -> Eithers.map (\t -> Paths.SubtermStepMapValue t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Core.TermLiteral v1 -> case v1 of
Core.LiteralInteger v2 -> case v2 of
Core.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractCore.stripWithDecodingError cx input)))),
(
Core.Name "optionalGiven",
(\input -> Eithers.map (\t -> Paths.SubtermStepOptionalGiven) (ExtractCore.decodeUnit cx input))),
(Core.Name "pairFirst", (\input -> Eithers.map (\t -> Paths.SubtermStepPairFirst) (ExtractCore.decodeUnit cx input))),
(Core.Name "pairSecond", (\input -> Eithers.map (\t -> Paths.SubtermStepPairSecond) (ExtractCore.decodeUnit cx input))),
(Core.Name "recordField", (\input -> Eithers.map (\t -> Paths.SubtermStepRecordField t) (DecodeCore.name cx input))),
(
Core.Name "setElement",
(\input -> Eithers.map (\t -> Paths.SubtermStepSetElement t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Core.TermLiteral v1 -> case v1 of
Core.LiteralInteger v2 -> case v2 of
Core.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractCore.stripWithDecodingError cx input)))),
(
Core.Name "typeApplicationBody",
(\input -> Eithers.map (\t -> Paths.SubtermStepTypeApplicationBody) (ExtractCore.decodeUnit cx input))),
(
Core.Name "typeLambdaBody",
(\input -> Eithers.map (\t -> Paths.SubtermStepTypeLambdaBody) (ExtractCore.decodeUnit cx input))),
(Core.Name "wrapBody", (\input -> Eithers.map (\t -> Paths.SubtermStepWrapBody) (ExtractCore.decodeUnit cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Core.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtypeAttribute
subtypeAttribute :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtypeAttribute
subtypeAttribute cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "path" subtypePath fieldMap cx) (\field_path -> Eithers.bind (ExtractCore.requireField "target" typeAttribute fieldMap cx) (\field_target -> Right (Paths.SubtypeAttribute {
Paths.subtypeAttributePath = field_path,
Paths.subtypeAttributeTarget = field_target}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtypeAttribute")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtypeEdge
subtypeEdge :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtypeEdge
subtypeEdge cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "path" subtypePath fieldMap cx) (\field_path -> Eithers.bind (ExtractCore.requireField "target" DecodeCore.name fieldMap cx) (\field_target -> Right (Paths.SubtypeEdge {
Paths.subtypeEdgePath = field_path,
Paths.subtypeEdgeTarget = field_target}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtypeEdge")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtypeGraph
subtypeGraph :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtypeGraph
subtypeGraph cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "nodes" (ExtractCore.decodeList subtypeNode) fieldMap cx) (\field_nodes -> Right (Paths.SubtypeGraph {
Paths.subtypeGraphNodes = field_nodes})))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtypeGraph")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtypeLink
subtypeLink :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtypeLink
subtypeLink cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermInject v0 ->
let field = Core.injectionField v0
fname = Core.fieldName field
fterm = Core.fieldTerm field
variantMap =
Maps.fromList [
(Core.Name "edge", (\input -> Eithers.map (\t -> Paths.SubtypeLinkEdge t) (subtypeEdge cx input))),
(Core.Name "property", (\input -> Eithers.map (\t -> Paths.SubtypeLinkProperty t) (subtypeProperty cx input))),
(Core.Name "attribute", (\input -> Eithers.map (\t -> Paths.SubtypeLinkAttribute t) (subtypeAttribute cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Core.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtypeNode
subtypeNode :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtypeNode
subtypeNode cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "name" DecodeCore.name fieldMap cx) (\field_name -> Eithers.bind (ExtractCore.requireField "links" (ExtractCore.decodeList subtypeLink) fieldMap cx) (\field_links -> Right (Paths.SubtypeNode {
Paths.subtypeNodeName = field_name,
Paths.subtypeNodeLinks = field_links}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtypeNode")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtypePath
subtypePath :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtypePath
subtypePath cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermWrap v0 -> Eithers.map (\b -> Paths.SubtypePath b) (ExtractCore.decodeList subtypeStep cx (Core.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtypeProperty
subtypeProperty :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtypeProperty
subtypeProperty cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermRecord v0 ->
let fieldMap = ExtractCore.toFieldMap v0
in (Eithers.bind (ExtractCore.requireField "path" subtypePath fieldMap cx) (\field_path -> Eithers.bind (ExtractCore.requireField "target" DecodeCore.type_ fieldMap cx) (\field_target -> Right (Paths.SubtypeProperty {
Paths.subtypePropertyPath = field_path,
Paths.subtypePropertyTarget = field_target}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.paths.SubtypeProperty")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.SubtypeStep
subtypeStep :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.SubtypeStep
subtypeStep cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermInject v0 ->
let field = Core.injectionField v0
fname = Core.fieldName field
fterm = Core.fieldTerm field
variantMap =
Maps.fromList [
(
Core.Name "annotatedBody",
(\input -> Eithers.map (\t -> Paths.SubtypeStepAnnotatedBody) (ExtractCore.decodeUnit cx input))),
(
Core.Name "applicationArgument",
(\input -> Eithers.map (\t -> Paths.SubtypeStepApplicationArgument) (ExtractCore.decodeUnit cx input))),
(
Core.Name "applicationFunction",
(\input -> Eithers.map (\t -> Paths.SubtypeStepApplicationFunction) (ExtractCore.decodeUnit cx input))),
(Core.Name "effectValue", (\input -> Eithers.map (\t -> Paths.SubtypeStepEffectValue) (ExtractCore.decodeUnit cx input))),
(Core.Name "eitherLeft", (\input -> Eithers.map (\t -> Paths.SubtypeStepEitherLeft) (ExtractCore.decodeUnit cx input))),
(Core.Name "eitherRight", (\input -> Eithers.map (\t -> Paths.SubtypeStepEitherRight) (ExtractCore.decodeUnit cx input))),
(Core.Name "forallBody", (\input -> Eithers.map (\t -> Paths.SubtypeStepForallBody) (ExtractCore.decodeUnit cx input))),
(
Core.Name "functionCodomain",
(\input -> Eithers.map (\t -> Paths.SubtypeStepFunctionCodomain) (ExtractCore.decodeUnit cx input))),
(
Core.Name "functionDomain",
(\input -> Eithers.map (\t -> Paths.SubtypeStepFunctionDomain) (ExtractCore.decodeUnit cx input))),
(Core.Name "listElement", (\input -> Eithers.map (\t -> Paths.SubtypeStepListElement) (ExtractCore.decodeUnit cx input))),
(Core.Name "mapKeys", (\input -> Eithers.map (\t -> Paths.SubtypeStepMapKeys) (ExtractCore.decodeUnit cx input))),
(Core.Name "mapValues", (\input -> Eithers.map (\t -> Paths.SubtypeStepMapValues) (ExtractCore.decodeUnit cx input))),
(
Core.Name "optionalElement",
(\input -> Eithers.map (\t -> Paths.SubtypeStepOptionalElement) (ExtractCore.decodeUnit cx input))),
(Core.Name "pairFirst", (\input -> Eithers.map (\t -> Paths.SubtypeStepPairFirst) (ExtractCore.decodeUnit cx input))),
(Core.Name "pairSecond", (\input -> Eithers.map (\t -> Paths.SubtypeStepPairSecond) (ExtractCore.decodeUnit cx input))),
(Core.Name "recordField", (\input -> Eithers.map (\t -> Paths.SubtypeStepRecordField t) (DecodeCore.name cx input))),
(Core.Name "setElement", (\input -> Eithers.map (\t -> Paths.SubtypeStepSetElement) (ExtractCore.decodeUnit cx input))),
(Core.Name "unionField", (\input -> Eithers.map (\t -> Paths.SubtypeStepUnionField t) (DecodeCore.name cx input))),
(Core.Name "wrapBody", (\input -> Eithers.map (\t -> Paths.SubtypeStepWrapBody) (ExtractCore.decodeUnit cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Core.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.TermAttribute
termAttribute :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.TermAttribute
termAttribute cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermInject v0 ->
let field = Core.injectionField v0
fname = Core.fieldName field
fterm = Core.fieldTerm field
variantMap =
Maps.fromList [
(Core.Name "casesTypeName", (\input -> Eithers.map (\t -> Paths.TermAttributeCasesTypeName t) (DecodeCore.name cx input))),
(
Core.Name "injectTypeName",
(\input -> Eithers.map (\t -> Paths.TermAttributeInjectTypeName t) (DecodeCore.name cx input))),
(
Core.Name "lambdaDomainGiven",
(\input -> Eithers.map (\t -> Paths.TermAttributeLambdaDomainGiven t) (DecodeCore.type_ cx input))),
(
Core.Name "lambdaParameter",
(\input -> Eithers.map (\t -> Paths.TermAttributeLambdaParameter t) (DecodeCore.name cx input))),
(
Core.Name "letBindingTypeSchemeGiven",
(\input -> Eithers.map (\t -> Paths.TermAttributeLetBindingTypeSchemeGiven t) (ExtractCore.decodePair DecodeCore.name DecodeCore.typeScheme cx input))),
(
Core.Name "projectFieldName",
(\input -> Eithers.map (\t -> Paths.TermAttributeProjectFieldName t) (DecodeCore.name cx input))),
(
Core.Name "projectTypeName",
(\input -> Eithers.map (\t -> Paths.TermAttributeProjectTypeName t) (DecodeCore.name cx input))),
(
Core.Name "recordTypeName",
(\input -> Eithers.map (\t -> Paths.TermAttributeRecordTypeName t) (DecodeCore.name cx input))),
(
Core.Name "typeApplicationType",
(\input -> Eithers.map (\t -> Paths.TermAttributeTypeApplicationType t) (DecodeCore.type_ cx input))),
(
Core.Name "typeLambdaParameter",
(\input -> Eithers.map (\t -> Paths.TermAttributeTypeLambdaParameter t) (DecodeCore.name cx input))),
(Core.Name "wrapTypeName", (\input -> Eithers.map (\t -> Paths.TermAttributeWrapTypeName t) (DecodeCore.name cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Core.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractCore.stripWithDecodingError cx raw)
-- | Decoder for hydra.paths.TypeAttribute
typeAttribute :: Graph.Graph -> Core.Term -> Either Errors.DecodingError Paths.TypeAttribute
typeAttribute cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Core.TermInject v0 ->
let field = Core.injectionField v0
fname = Core.fieldName field
fterm = Core.fieldTerm field
variantMap =
Maps.fromList [
(
Core.Name "annotatedAnnotation",
(\input -> Eithers.map (\t -> Paths.TypeAttributeAnnotatedAnnotation t) (DecodeCore.term cx input))),
(
Core.Name "forallParameter",
(\input -> Eithers.map (\t -> Paths.TypeAttributeForallParameter t) (DecodeCore.name cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Core.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractCore.stripWithDecodingError cx raw)