hydra-pg-0.18.0: src/main/haskell/Hydra/Pg/Decode/Neo4j/Model.hs
-- Note: this is an automatically generated file. Do not edit.
-- | Term decoders for hydra.pg.neo4j.model
module Hydra.Pg.Decode.Neo4j.Model where
import qualified Hydra.Core.Decode.Model as DecodeModel
import qualified Hydra.Core.Errors as Errors
import qualified Hydra.Core.Extract.Model as ExtractModel
import qualified Hydra.Core.Graph as Graph
import qualified Hydra.Core.Lexical as Lexical
import qualified Hydra.Core.Overlay.Haskell.Lib.Eithers as Eithers
import qualified Hydra.Core.Overlay.Haskell.Lib.Maps as Maps
import qualified Hydra.Core.Overlay.Haskell.Lib.Optionals as Optionals
import qualified Hydra.Core.Overlay.Haskell.Lib.Strings as Strings
import qualified Hydra.Core.Model as Model
import qualified Hydra.Core.Rewriting as Rewriting
import qualified Hydra.Core.Util as Util
import qualified Hydra.Pg.Neo4j.Model as Neo4jModel
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.pg.neo4j.model.Constraint
constraint :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Constraint
constraint cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermInject v0 ->
let field = Model.injectionField v0
fname = Model.fieldName field
fterm = Model.fieldTerm field
variantMap =
Maps.fromList [
(Model.Name "key", (\input -> Eithers.map (\t -> Neo4jModel.ConstraintKey t) (keyConstraint cx input))),
(
Model.Name "propertyExistence",
(\input -> Eithers.map (\t -> Neo4jModel.ConstraintPropertyExistence t) (propertyExistenceConstraint cx input))),
(
Model.Name "propertyType",
(\input -> Eithers.map (\t -> Neo4jModel.ConstraintPropertyType t) (propertyTypeConstraint cx input))),
(
Model.Name "propertyUniqueness",
(\input -> Eithers.map (\t -> Neo4jModel.ConstraintPropertyUniqueness t) (propertyUniquenessConstraint cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Model.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.ConstraintDefinition
constraintDefinition :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.ConstraintDefinition
constraintDefinition cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "name" (ExtractModel.decodeMaybe (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralString v2 -> Right v2
_ -> Left (Errors.DecodingError "expected string literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2))) fieldMap cx) (\field_name -> Eithers.bind (ExtractModel.requireField "body" constraint fieldMap cx) (\field_body -> Right (Neo4jModel.ConstraintDefinition {
Neo4jModel.constraintDefinitionName = field_name,
Neo4jModel.constraintDefinitionBody = field_body}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.ConstraintDefinition")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.Element
element :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Element
element cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermInject v0 ->
let field = Model.injectionField v0
fname = Model.fieldName field
fterm = Model.fieldTerm field
variantMap =
Maps.fromList [
(Model.Name "node", (\input -> Eithers.map (\t -> Neo4jModel.ElementNode t) (node cx input))),
(Model.Name "relationship", (\input -> Eithers.map (\t -> Neo4jModel.ElementRelationship t) (relationship cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Model.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.ElementId
elementId :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.ElementId
elementId cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermWrap v0 -> Eithers.map (\b -> Neo4jModel.ElementId b) ((\raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralString v2 -> Right v2
_ -> Left (Errors.DecodingError "expected string literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx raw2)) (Model.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.GraphType
graphType :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.GraphType
graphType cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "nodes" (ExtractModel.decodeList nodeElementType) fieldMap cx) (\field_nodes -> Eithers.bind (ExtractModel.requireField "relationships" (ExtractModel.decodeList relationshipElementType) fieldMap cx) (\field_relationships -> Right (Neo4jModel.GraphType {
Neo4jModel.graphTypeNodes = field_nodes,
Neo4jModel.graphTypeRelationships = field_relationships}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.GraphType")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.IsoDuration
isoDuration :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.IsoDuration
isoDuration cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "months" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt64 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int64 value")
_ -> Left (Errors.DecodingError "expected int64 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_months -> Eithers.bind (ExtractModel.requireField "days" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt64 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int64 value")
_ -> Left (Errors.DecodingError "expected int64 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_days -> Eithers.bind (ExtractModel.requireField "seconds" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt64 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int64 value")
_ -> Left (Errors.DecodingError "expected int64 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_seconds -> Eithers.bind (ExtractModel.requireField "nanoseconds" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_nanoseconds -> Right (Neo4jModel.IsoDuration {
Neo4jModel.isoDurationMonths = field_months,
Neo4jModel.isoDurationDays = field_days,
Neo4jModel.isoDurationSeconds = field_seconds,
Neo4jModel.isoDurationNanoseconds = field_nanoseconds}))))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.IsoDuration")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.Key
key :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Key
key cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermWrap v0 -> Eithers.map (\b -> Neo4jModel.Key b) ((\raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralString v2 -> Right v2
_ -> Left (Errors.DecodingError "expected string literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx raw2)) (Model.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.KeyConstraint
keyConstraint :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.KeyConstraint
keyConstraint cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "properties" (ExtractModel.decodeList key) fieldMap cx) (\field_properties -> Right (Neo4jModel.KeyConstraint {
Neo4jModel.keyConstraintProperties = field_properties})))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.KeyConstraint")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.LocalDate
localDate :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.LocalDate
localDate cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "year" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_year -> Eithers.bind (ExtractModel.requireField "month" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_month -> Eithers.bind (ExtractModel.requireField "day" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_day -> Right (Neo4jModel.LocalDate {
Neo4jModel.localDateYear = field_year,
Neo4jModel.localDateMonth = field_month,
Neo4jModel.localDateDay = field_day})))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.LocalDate")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.LocalDateTime
localDateTime :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.LocalDateTime
localDateTime cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "date" localDate fieldMap cx) (\field_date -> Eithers.bind (ExtractModel.requireField "time" localTime fieldMap cx) (\field_time -> Right (Neo4jModel.LocalDateTime {
Neo4jModel.localDateTimeDate = field_date,
Neo4jModel.localDateTimeTime = field_time}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.LocalDateTime")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.LocalTime
localTime :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.LocalTime
localTime cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "hour" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_hour -> Eithers.bind (ExtractModel.requireField "minute" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_minute -> Eithers.bind (ExtractModel.requireField "second" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_second -> Eithers.bind (ExtractModel.requireField "nanosecond" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_nanosecond -> Right (Neo4jModel.LocalTime {
Neo4jModel.localTimeHour = field_hour,
Neo4jModel.localTimeMinute = field_minute,
Neo4jModel.localTimeSecond = field_second,
Neo4jModel.localTimeNanosecond = field_nanosecond}))))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.LocalTime")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.Node
node :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Node
node cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "id" elementId fieldMap cx) (\field_id -> Eithers.bind (ExtractModel.requireField "labels" (ExtractModel.decodeSet nodeLabel) fieldMap cx) (\field_labels -> Eithers.bind (ExtractModel.requireField "properties" (ExtractModel.decodeMap key value) fieldMap cx) (\field_properties -> Right (Neo4jModel.Node {
Neo4jModel.nodeId = field_id,
Neo4jModel.nodeLabels = field_labels,
Neo4jModel.nodeProperties = field_properties})))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.Node")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.NodeElementType
nodeElementType :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.NodeElementType
nodeElementType cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "identifyingLabel" nodeLabel fieldMap cx) (\field_identifyingLabel -> Eithers.bind (ExtractModel.requireField "impliedLabels" (ExtractModel.decodeSet nodeLabel) fieldMap cx) (\field_impliedLabels -> Eithers.bind (ExtractModel.requireField "constraints" (ExtractModel.decodeList constraintDefinition) fieldMap cx) (\field_constraints -> Right (Neo4jModel.NodeElementType {
Neo4jModel.nodeElementTypeIdentifyingLabel = field_identifyingLabel,
Neo4jModel.nodeElementTypeImpliedLabels = field_impliedLabels,
Neo4jModel.nodeElementTypeConstraints = field_constraints})))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.NodeElementType")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.NodeLabel
nodeLabel :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.NodeLabel
nodeLabel cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermWrap v0 -> Eithers.map (\b -> Neo4jModel.NodeLabel b) ((\raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralString v2 -> Right v2
_ -> Left (Errors.DecodingError "expected string literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx raw2)) (Model.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.OffsetTime
offsetTime :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.OffsetTime
offsetTime cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "time" localTime fieldMap cx) (\field_time -> Eithers.bind (ExtractModel.requireField "offset" zoneOffset fieldMap cx) (\field_offset -> Right (Neo4jModel.OffsetTime {
Neo4jModel.offsetTimeTime = field_time,
Neo4jModel.offsetTimeOffset = field_offset}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.OffsetTime")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.Path
path :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Path
path cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "start" node fieldMap cx) (\field_start -> Eithers.bind (ExtractModel.requireField "segments" (ExtractModel.decodeList segment) fieldMap cx) (\field_segments -> Right (Neo4jModel.Path {
Neo4jModel.pathStart = field_start,
Neo4jModel.pathSegments = field_segments}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.Path")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.Point
point :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Point
point cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "srid" spatialReferenceIdentifier fieldMap cx) (\field_srid -> Eithers.bind (ExtractModel.requireField "x" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralFloat v2 -> case v2 of
Model.FloatValueFloat64 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected float64 value")
_ -> Left (Errors.DecodingError "expected float64 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_x -> Eithers.bind (ExtractModel.requireField "y" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralFloat v2 -> case v2 of
Model.FloatValueFloat64 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected float64 value")
_ -> Left (Errors.DecodingError "expected float64 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_y -> Eithers.bind (ExtractModel.requireField "z" (ExtractModel.decodeMaybe (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralFloat v2 -> case v2 of
Model.FloatValueFloat64 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected float64 value")
_ -> Left (Errors.DecodingError "expected float64 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2))) fieldMap cx) (\field_z -> Right (Neo4jModel.Point {
Neo4jModel.pointSrid = field_srid,
Neo4jModel.pointX = field_x,
Neo4jModel.pointY = field_y,
Neo4jModel.pointZ = field_z}))))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.Point")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.PropertyExistenceConstraint
propertyExistenceConstraint :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.PropertyExistenceConstraint
propertyExistenceConstraint cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "property" key fieldMap cx) (\field_property -> Right (Neo4jModel.PropertyExistenceConstraint {
Neo4jModel.propertyExistenceConstraintProperty = field_property})))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.PropertyExistenceConstraint")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.PropertyTypeConstraint
propertyTypeConstraint :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.PropertyTypeConstraint
propertyTypeConstraint cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "property" key fieldMap cx) (\field_property -> Eithers.bind (ExtractModel.requireField "type" valueType fieldMap cx) (\field_type -> Right (Neo4jModel.PropertyTypeConstraint {
Neo4jModel.propertyTypeConstraintProperty = field_property,
Neo4jModel.propertyTypeConstraintType = field_type}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.PropertyTypeConstraint")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.PropertyUniquenessConstraint
propertyUniquenessConstraint :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.PropertyUniquenessConstraint
propertyUniquenessConstraint cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "properties" (ExtractModel.decodeList key) fieldMap cx) (\field_properties -> Right (Neo4jModel.PropertyUniquenessConstraint {
Neo4jModel.propertyUniquenessConstraintProperties = field_properties})))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.PropertyUniquenessConstraint")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.Relationship
relationship :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Relationship
relationship cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "id" elementId fieldMap cx) (\field_id -> Eithers.bind (ExtractModel.requireField "properties" (ExtractModel.decodeMap key value) fieldMap cx) (\field_properties -> Eithers.bind (ExtractModel.requireField "type" relationshipType fieldMap cx) (\field_type -> Eithers.bind (ExtractModel.requireField "start" elementId fieldMap cx) (\field_start -> Eithers.bind (ExtractModel.requireField "end" elementId fieldMap cx) (\field_end -> Right (Neo4jModel.Relationship {
Neo4jModel.relationshipId = field_id,
Neo4jModel.relationshipProperties = field_properties,
Neo4jModel.relationshipType = field_type,
Neo4jModel.relationshipStart = field_start,
Neo4jModel.relationshipEnd = field_end})))))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.Relationship")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.RelationshipElementType
relationshipElementType :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.RelationshipElementType
relationshipElementType cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "type" relationshipType fieldMap cx) (\field_type -> Eithers.bind (ExtractModel.requireField "startLabel" nodeLabel fieldMap cx) (\field_startLabel -> Eithers.bind (ExtractModel.requireField "endLabel" nodeLabel fieldMap cx) (\field_endLabel -> Eithers.bind (ExtractModel.requireField "constraints" (ExtractModel.decodeList constraintDefinition) fieldMap cx) (\field_constraints -> Right (Neo4jModel.RelationshipElementType {
Neo4jModel.relationshipElementTypeType = field_type,
Neo4jModel.relationshipElementTypeStartLabel = field_startLabel,
Neo4jModel.relationshipElementTypeEndLabel = field_endLabel,
Neo4jModel.relationshipElementTypeConstraints = field_constraints}))))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.RelationshipElementType")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.RelationshipType
relationshipType :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.RelationshipType
relationshipType cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermWrap v0 -> Eithers.map (\b -> Neo4jModel.RelationshipType b) ((\raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralString v2 -> Right v2
_ -> Left (Errors.DecodingError "expected string literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx raw2)) (Model.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.Segment
segment :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Segment
segment cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "relationship" relationship fieldMap cx) (\field_relationship -> Eithers.bind (ExtractModel.requireField "end" node fieldMap cx) (\field_end -> Right (Neo4jModel.Segment {
Neo4jModel.segmentRelationship = field_relationship,
Neo4jModel.segmentEnd = field_end}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.Segment")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.SpatialReferenceIdentifier
spatialReferenceIdentifier :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.SpatialReferenceIdentifier
spatialReferenceIdentifier cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermWrap v0 -> Eithers.map (\b -> Neo4jModel.SpatialReferenceIdentifier b) ((\raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx raw2)) (Model.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.Value
value :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.Value
value cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermInject v0 ->
let field = Model.injectionField v0
fname = Model.fieldName field
fterm = Model.fieldTerm field
variantMap =
Maps.fromList [
(
Model.Name "boolean",
(\input -> Eithers.map (\t -> Neo4jModel.ValueBoolean t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralBoolean v2 -> Right v2
_ -> Left (Errors.DecodingError "expected boolean literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx input)))),
(
Model.Name "bytes",
(\input -> Eithers.map (\t -> Neo4jModel.ValueBytes t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralBinary v2 -> Right v2
_ -> Left (Errors.DecodingError "expected binary literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx input)))),
(Model.Name "date", (\input -> Eithers.map (\t -> Neo4jModel.ValueDate t) (localDate cx input))),
(Model.Name "dateTime", (\input -> Eithers.map (\t -> Neo4jModel.ValueDateTime t) (zonedDateTime cx input))),
(Model.Name "duration", (\input -> Eithers.map (\t -> Neo4jModel.ValueDuration t) (isoDuration cx input))),
(
Model.Name "float",
(\input -> Eithers.map (\t -> Neo4jModel.ValueFloat t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralFloat v2 -> case v2 of
Model.FloatValueFloat64 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected float64 value")
_ -> Left (Errors.DecodingError "expected float64 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx input)))),
(
Model.Name "integer",
(\input -> Eithers.map (\t -> Neo4jModel.ValueInteger t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt64 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int64 value")
_ -> Left (Errors.DecodingError "expected int64 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx input)))),
(Model.Name "list", (\input -> Eithers.map (\t -> Neo4jModel.ValueList t) (ExtractModel.decodeList value cx input))),
(Model.Name "localDateTime", (\input -> Eithers.map (\t -> Neo4jModel.ValueLocalDateTime t) (localDateTime cx input))),
(Model.Name "localTime", (\input -> Eithers.map (\t -> Neo4jModel.ValueLocalTime t) (localTime cx input))),
(Model.Name "map", (\input -> Eithers.map (\t -> Neo4jModel.ValueMap t) (ExtractModel.decodeMap key value cx input))),
(Model.Name "node", (\input -> Eithers.map (\t -> Neo4jModel.ValueNode t) (node cx input))),
(Model.Name "null", (\input -> Eithers.map (\t -> Neo4jModel.ValueNull) (ExtractModel.decodeUnit cx input))),
(Model.Name "path", (\input -> Eithers.map (\t -> Neo4jModel.ValuePath t) (path cx input))),
(Model.Name "point", (\input -> Eithers.map (\t -> Neo4jModel.ValuePoint t) (point cx input))),
(Model.Name "relationship", (\input -> Eithers.map (\t -> Neo4jModel.ValueRelationship t) (relationship cx input))),
(
Model.Name "string",
(\input -> Eithers.map (\t -> Neo4jModel.ValueString t) (Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralString v2 -> Right v2
_ -> Left (Errors.DecodingError "expected string literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx input)))),
(Model.Name "time", (\input -> Eithers.map (\t -> Neo4jModel.ValueTime t) (offsetTime cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Model.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.ValueType
valueType :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.ValueType
valueType cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermInject v0 ->
let field = Model.injectionField v0
fname = Model.fieldName field
fterm = Model.fieldTerm field
variantMap =
Maps.fromList [
(Model.Name "boolean", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeBoolean) (ExtractModel.decodeUnit cx input))),
(Model.Name "string", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeString) (ExtractModel.decodeUnit cx input))),
(Model.Name "integer", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeInteger) (ExtractModel.decodeUnit cx input))),
(Model.Name "float", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeFloat) (ExtractModel.decodeUnit cx input))),
(Model.Name "date", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeDate) (ExtractModel.decodeUnit cx input))),
(Model.Name "localTime", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeLocalTime) (ExtractModel.decodeUnit cx input))),
(Model.Name "zonedTime", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeZonedTime) (ExtractModel.decodeUnit cx input))),
(
Model.Name "localDateTime",
(\input -> Eithers.map (\t -> Neo4jModel.ValueTypeLocalDateTime) (ExtractModel.decodeUnit cx input))),
(
Model.Name "zonedDateTime",
(\input -> Eithers.map (\t -> Neo4jModel.ValueTypeZonedDateTime) (ExtractModel.decodeUnit cx input))),
(Model.Name "duration", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeDuration) (ExtractModel.decodeUnit cx input))),
(Model.Name "point", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypePoint) (ExtractModel.decodeUnit cx input))),
(Model.Name "list", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeList t) (valueType cx input))),
(Model.Name "vector", (\input -> Eithers.map (\t -> Neo4jModel.ValueTypeVector t) (vectorType cx input))),
(
Model.Name "union",
(\input -> Eithers.map (\t -> Neo4jModel.ValueTypeUnion t) (ExtractModel.decodeList valueType cx input)))]
in (Optionals.match (Maps.lookup fname variantMap) (Left (Errors.DecodingError (Strings.concat [
"no such field ",
(Model.unName fname),
" in union"]))) (\f -> f fterm))
_ -> Left (Errors.DecodingError "expected union")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.VectorType
vectorType :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.VectorType
vectorType cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "element" valueType fieldMap cx) (\field_element -> Eithers.bind (ExtractModel.requireField "dimension" (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2)) fieldMap cx) (\field_dimension -> Right (Neo4jModel.VectorType {
Neo4jModel.vectorTypeElement = field_element,
Neo4jModel.vectorTypeDimension = field_dimension}))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.VectorType")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.ZoneId
zoneId :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.ZoneId
zoneId cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermWrap v0 -> Eithers.map (\b -> Neo4jModel.ZoneId b) ((\raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralString v2 -> Right v2
_ -> Left (Errors.DecodingError "expected string literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx raw2)) (Model.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.ZoneOffset
zoneOffset :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.ZoneOffset
zoneOffset cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermWrap v0 -> Eithers.map (\b -> Neo4jModel.ZoneOffset b) ((\raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of
Model.TermLiteral v1 -> case v1 of
Model.LiteralInteger v2 -> case v2 of
Model.IntegerValueInt32 v3 -> Right v3
_ -> Left (Errors.DecodingError "expected int32 value")
_ -> Left (Errors.DecodingError "expected int32 literal")
_ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx raw2)) (Model.wrappedTermBody v0))
_ -> Left (Errors.DecodingError "expected wrapped type")) (ExtractModel.stripWithDecodingError cx raw)
-- | Decoder for hydra.pg.neo4j.model.ZonedDateTime
zonedDateTime :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Neo4jModel.ZonedDateTime
zonedDateTime cx raw =
Eithers.either (\err -> Left err) (\stripped -> case stripped of
Model.TermRecord v0 ->
let fieldMap = ExtractModel.toFieldMap v0
in (Eithers.bind (ExtractModel.requireField "dateTime" localDateTime fieldMap cx) (\field_dateTime -> Eithers.bind (ExtractModel.requireField "offset" zoneOffset fieldMap cx) (\field_offset -> Eithers.bind (ExtractModel.requireField "zone" zoneId fieldMap cx) (\field_zone -> Right (Neo4jModel.ZonedDateTime {
Neo4jModel.zonedDateTimeDateTime = field_dateTime,
Neo4jModel.zonedDateTimeOffset = field_offset,
Neo4jModel.zonedDateTimeZone = field_zone})))))
_ -> Left (Errors.DecodingError "expected a record of type hydra.pg.neo4j.model.ZonedDateTime")) (ExtractModel.stripWithDecodingError cx raw)