hydra-kernel-0.18.0: src/main/haskell/Hydra/Core/Encode/Diff.hs
-- Note: this is an automatically generated file. Do not edit.
-- | Term encoders for hydra.core.diff
module Hydra.Core.Encode.Diff where
import qualified Hydra.Core.Diff as Diff
import qualified Hydra.Core.Encode.Model as EncodeModel
import qualified Hydra.Core.Overlay.Haskell.Lib.Lists as Lists
import qualified Hydra.Core.Overlay.Haskell.Lib.Maps as Maps
import qualified Hydra.Core.Model as Model
import Prelude hiding (Enum, Ordering, decodeFloat, encodeFloat, fail, lines, map, pure, sum, unlines)
import qualified Data.Scientific as Sci
import Data.Void
-- | Encoder for hydra.core.diff.Edit
edit :: (a -> Model.Term) -> (s -> Model.Term) -> Diff.Edit a s -> Model.Term
edit a s x =
case x of
Diff.EditRetain -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.Edit"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "retain"),
Model.fieldTerm = Model.TermUnit}})
Diff.EditSet v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.Edit"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "set"),
Model.fieldTerm = (a v0)}})
Diff.EditDelete -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.Edit"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "delete"),
Model.fieldTerm = Model.TermUnit}})
Diff.EditDescend v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.Edit"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "descend"),
Model.fieldTerm = (Model.TermList (Lists.map (stepEdit a s) v0))}})
-- | Encoder for hydra.core.diff.Hole
hole :: (t -> Model.Term) -> (s -> Model.Term) -> Diff.Hole t s -> Model.Term
hole t s x =
Model.TermRecord (Model.Record {
Model.recordTypeName = (Model.Name "hydra.core.diff.Hole"),
Model.recordFields = [
Model.Field {
Model.fieldName = (Model.Name "path"),
Model.fieldTerm = ((\xs -> Model.TermList (Lists.map s xs)) (Diff.holePath x))},
Model.Field {
Model.fieldName = (Model.Name "type"),
Model.fieldTerm = (t (Diff.holeType x))}]})
-- | Encoder for hydra.core.diff.HoleFiller
holeFiller :: (v -> Model.Term) -> (s -> Model.Term) -> Diff.HoleFiller v s -> Model.Term
holeFiller v s x =
Model.TermRecord (Model.Record {
Model.recordTypeName = (Model.Name "hydra.core.diff.HoleFiller"),
Model.recordFields = [
Model.Field {
Model.fieldName = (Model.Name "path"),
Model.fieldTerm = ((\xs -> Model.TermList (Lists.map s xs)) (Diff.holeFillerPath x))},
Model.Field {
Model.fieldName = (Model.Name "value"),
Model.fieldTerm = (v (Diff.holeFillerValue x))}]})
-- | Encoder for hydra.core.diff.InvalidFillError
invalidFillError :: (t -> Model.Term) -> (v -> Model.Term) -> (s -> Model.Term) -> Diff.InvalidFillError t v s -> Model.Term
invalidFillError t v s x =
case x of
Diff.InvalidFillErrorIllTyped v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.InvalidFillError"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "illTyped"),
Model.fieldTerm = (hole t s v0)}})
Diff.InvalidFillErrorMissingFill v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.InvalidFillError"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "missingFill"),
Model.fieldTerm = (hole t s v0)}})
Diff.InvalidFillErrorExtraFill v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.InvalidFillError"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "extraFill"),
Model.fieldTerm = (Model.TermLiteral (Model.LiteralInteger (Model.IntegerValueInt32 v0)))}})
-- | Encoder for hydra.core.diff.MigrationError
migrationError :: (t -> Model.Term) -> (v -> Model.Term) -> (s -> Model.Term) -> Diff.MigrationError t v s -> Model.Term
migrationError t v s x =
case x of
Diff.MigrationErrorNotAnInstance v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.MigrationError"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "notAnInstance"),
Model.fieldTerm = (v v0)}})
Diff.MigrationErrorOutOfRange v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.MigrationError"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "outOfRange"),
Model.fieldTerm = (v v0)}})
Diff.MigrationErrorRejectedVariant v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.MigrationError"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "rejectedVariant"),
Model.fieldTerm = (v v0)}})
Diff.MigrationErrorIllTypedResult v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.MigrationError"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "illTypedResult"),
Model.fieldTerm = (mistyped t v v0)}})
Diff.MigrationErrorUnfilledHole v0 -> Model.TermInject (Model.Injection {
Model.injectionTypeName = (Model.Name "hydra.core.diff.MigrationError"),
Model.injectionField = Model.Field {
Model.fieldName = (Model.Name "unfilledHole"),
Model.fieldTerm = (hole t s v0)}})
-- | Encoder for hydra.core.diff.MigrationPlan
migrationPlan :: Ord n => ((n -> Model.Term) -> (t -> Model.Term) -> (s -> Model.Term) -> Diff.MigrationPlan n t s -> Model.Term)
migrationPlan n t s x =
Model.TermRecord (Model.Record {
Model.recordTypeName = (Model.Name "hydra.core.diff.MigrationPlan"),
Model.recordFields = [
Model.Field {
Model.fieldName = (Model.Name "edits"),
Model.fieldTerm = ((\m -> Model.TermMap (Maps.bimap n (edit t s) m)) (Diff.migrationPlanEdits x))},
Model.Field {
Model.fieldName = (Model.Name "holes"),
Model.fieldTerm = ((\xs -> Model.TermList (Lists.map (schemaHole n t s) xs)) (Diff.migrationPlanHoles x))}]})
-- | Encoder for hydra.core.diff.Mistyped
mistyped :: (t -> Model.Term) -> (v -> Model.Term) -> Diff.Mistyped t v -> Model.Term
mistyped t v x =
Model.TermRecord (Model.Record {
Model.recordTypeName = (Model.Name "hydra.core.diff.Mistyped"),
Model.recordFields = [
Model.Field {
Model.fieldName = (Model.Name "value"),
Model.fieldTerm = (v (Diff.mistypedValue x))},
Model.Field {
Model.fieldName = (Model.Name "type"),
Model.fieldTerm = (t (Diff.mistypedType x))}]})
-- | Encoder for hydra.core.diff.SchemaHole
schemaHole :: (n -> Model.Term) -> (t -> Model.Term) -> (s -> Model.Term) -> Diff.SchemaHole n t s -> Model.Term
schemaHole n t s x =
Model.TermRecord (Model.Record {
Model.recordTypeName = (Model.Name "hydra.core.diff.SchemaHole"),
Model.recordFields = [
Model.Field {
Model.fieldName = (Model.Name "typeName"),
Model.fieldTerm = (n (Diff.schemaHoleTypeName x))},
Model.Field {
Model.fieldName = (Model.Name "hole"),
Model.fieldTerm = (hole t s (Diff.schemaHoleHole x))}]})
-- | Encoder for hydra.core.diff.StepEdit
stepEdit :: (a -> Model.Term) -> (s -> Model.Term) -> Diff.StepEdit a s -> Model.Term
stepEdit a s x =
Model.TermRecord (Model.Record {
Model.recordTypeName = (Model.Name "hydra.core.diff.StepEdit"),
Model.recordFields = [
Model.Field {
Model.fieldName = (Model.Name "step"),
Model.fieldTerm = (s (Diff.stepEditStep x))},
Model.Field {
Model.fieldName = (Model.Name "edit"),
Model.fieldTerm = (edit a s (Diff.stepEditEdit x))}]})