packages feed

hydra-kernel-0.18.1: hydra-kernel-json/hydra/core/reduction.json

{
  "name": "hydra.core.reduction",
  "metadata": {
    "description": "Functions for reducing terms and types, i.e. performing computations.",
    "comments": [],
    "seeAlso": [],
    "provisions": []},
  "dependencies": [
    {"module": "hydra.core.annotations"},
    {"module": "hydra.core.arity"},
    {"module": "hydra.core.checking"},
    {"module": "hydra.core.encode.model"},
    {"module": "hydra.core.errors"},
    {"module": "hydra.core.extract.model"},
    {"module": "hydra.core.graph"},
    {"module": "hydra.core.lexical"},
    {"module": "hydra.core.lib.eithers"},
    {"module": "hydra.core.lib.equality"},
    {"module": "hydra.core.lib.lists"},
    {"module": "hydra.core.lib.literals"},
    {"module": "hydra.core.lib.logic"},
    {"module": "hydra.core.lib.maps"},
    {"module": "hydra.core.lib.math"},
    {"module": "hydra.core.lib.optionals"},
    {"module": "hydra.core.lib.ordering"},
    {"module": "hydra.core.lib.pairs"},
    {"module": "hydra.core.lib.sets"},
    {"module": "hydra.core.lib.strings"},
    {"module": "hydra.core.model"},
    {"module": "hydra.core.packaging"},
    {"module": "hydra.core.print.errors"},
    {"module": "hydra.core.resolution"},
    {"module": "hydra.core.rewriting"},
    {"module": "hydra.core.scoping"},
    {"module": "hydra.core.strip"},
    {"module": "hydra.core.variables"}],
  "definitions": [
    {
      "term": {
        "name": "hydra.core.reduction.alphaConvert",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {"name": "arg2", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Term"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "vold",
                "domain": {"variable": "hydra.core.model.Name"},
                "body": {
                  "lambda": {
                    "parameter": "vnew",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "lambda": {
                        "parameter": "term",
                        "domain": {"variable": "hydra.core.model.Term"},
                        "body": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "application": {"function": {"variable": "hydra.core.variables.replaceFreeTermVariable"}, "argument": {"variable": "vold"}}},
                                "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "variable", "term": {"variable": "vnew"}}}}}},
                            "argument": {"variable": "term"}}}}}}}}},
            "annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Alpha convert a variable in a term"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.betaReduceType",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg2", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "cx",
                    "domain": {"variable": "t0"},
                    "body": {
                      "lambda": {
                        "parameter": "graph",
                        "domain": {"variable": "hydra.core.graph.Graph"},
                        "body": {
                          "lambda": {
                            "parameter": "typ",
                            "domain": {"variable": "hydra.core.model.Type"},
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "reduceApp",
                                    "term": {
                                      "lambda": {
                                        "parameter": "app",
                                        "domain": {"variable": "hydra.core.model.ApplicationType"},
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "lhs",
                                                "term": {
                                                  "application": {
                                                    "function": {"project": {"typeName": "hydra.core.model.ApplicationType", "fieldName": "function"}},
                                                    "argument": {"variable": "app"}}},
                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "rhs",
                                                    "term": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.model.ApplicationType", "fieldName": "argument"}},
                                                        "argument": {"variable": "app"}}},
                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "cases": {
                                                        "typeName": "hydra.core.model.Type",
                                                        "cases": [
                                                          {
                                                            "name": "annotated",
                                                            "handler": {
                                                              "lambda": {
                                                                "parameter": "at",
                                                                "domain": {"variable": "hydra.core.model.AnnotatedType"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                "type": {"variable": "hydra.core.model.Type"}}},
                                                                            "type": {"variable": "hydra.core.model.Type"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"variable": "reduceApp"},
                                                                            "argument": {
                                                                              "record": {
                                                                                "typeName": "hydra.core.model.ApplicationType",
                                                                                "fields": [
                                                                                  {
                                                                                    "name": "function",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {"project": {"typeName": "hydra.core.model.AnnotatedType", "fieldName": "body"}},
                                                                                        "argument": {"variable": "at"}}}},
                                                                                  {"name": "argument", "term": {"variable": "rhs"}}]}}}}}},
                                                                    "argument": {
                                                                      "lambda": {
                                                                        "parameter": "a",
                                                                        "domain": {"variable": "hydra.core.model.Type"},
                                                                        "body": {
                                                                          "typeApplication": {
                                                                            "body": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "either": {
                                                                                    "right": {
                                                                                      "inject": {
                                                                                        "typeName": "hydra.core.model.Type",
                                                                                        "field": {
                                                                                          "name": "annotated",
                                                                                          "term": {
                                                                                            "record": {
                                                                                              "typeName": "hydra.core.model.AnnotatedType",
                                                                                              "fields": [
                                                                                                {"name": "body", "term": {"variable": "a"}},
                                                                                                {
                                                                                                  "name": "annotation",
                                                                                                  "term": {
                                                                                                    "application": {
                                                                                                      "function": {"project": {"typeName": "hydra.core.model.AnnotatedType", "fieldName": "annotation"}},
                                                                                                      "argument": {"variable": "at"}}}}]}}}}}}},
                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                            "type": {"variable": "hydra.core.model.Type"}}}}}}}}}},
                                                          {
                                                            "name": "forall",
                                                            "handler": {
                                                              "lambda": {
                                                                "parameter": "ft",
                                                                "domain": {"variable": "hydra.core.model.ForallType"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.reduction.betaReduceType"}, "type": {"variable": "t0"}}},
                                                                            "argument": {"variable": "cx"}}},
                                                                        "argument": {"variable": "graph"}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {"variable": "hydra.core.variables.replaceFreeTypeVariable"},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
                                                                                    "argument": {"variable": "ft"}}}}},
                                                                            "argument": {"variable": "rhs"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "body"}},
                                                                            "argument": {"variable": "ft"}}}}}}}}}},
                                                          {
                                                            "name": "variable",
                                                            "handler": {
                                                              "lambda": {
                                                                "parameter": "name",
                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                "type": {"variable": "hydra.core.model.Type"}}},
                                                                            "type": {"variable": "hydra.core.model.Type"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.resolution.requireType"}, "type": {"variable": "t0"}}},
                                                                                    "argument": {"variable": "cx"}}},
                                                                                "argument": {"variable": "graph"}}},
                                                                            "argument": {"variable": "name"}}}}},
                                                                    "argument": {
                                                                      "lambda": {
                                                                        "parameter": "t'",
                                                                        "domain": {"variable": "hydra.core.model.Type"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.reduction.betaReduceType"}, "type": {"variable": "t0"}}},
                                                                                    "argument": {"variable": "cx"}}},
                                                                                "argument": {"variable": "graph"}}},
                                                                            "argument": {
                                                                              "inject": {
                                                                                "typeName": "hydra.core.model.Type",
                                                                                "field": {
                                                                                  "name": "application",
                                                                                  "term": {
                                                                                    "record": {
                                                                                      "typeName": "hydra.core.model.ApplicationType",
                                                                                      "fields": [{"name": "function", "term": {"variable": "t'"}}, {"name": "argument", "term": {"variable": "rhs"}}]}}}}}}}}}}}}}}]}},
                                                    "argument": {"variable": "lhs"}}}}}}}}},
                                    "typeScheme": {
                                      "variables": [],
                                      "body": {
                                        "function": {
                                          "domain": {"variable": "hydra.core.model.ApplicationType"},
                                          "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
                                      "constraints": []}}],
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "mapExpr",
                                        "term": {
                                          "typeLambda": {
                                            "parameter": "t1",
                                            "body": {
                                              "lambda": {
                                                "parameter": "recurse",
                                                "domain": {
                                                  "function": {
                                                    "domain": {"variable": "t1"},
                                                    "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "t",
                                                    "domain": {"variable": "t1"},
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "findApp",
                                                            "term": {
                                                              "lambda": {
                                                                "parameter": "r",
                                                                "domain": {"variable": "hydra.core.model.Type"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "cases": {
                                                                        "typeName": "hydra.core.model.Type",
                                                                        "default": {
                                                                          "typeApplication": {
                                                                            "body": {"typeApplication": {"body": {"either": {"right": {"variable": "r"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                            "type": {"variable": "hydra.core.model.Type"}}},
                                                                        "cases": [
                                                                          {
                                                                            "name": "application",
                                                                            "handler": {
                                                                              "lambda": {
                                                                                "parameter": "a",
                                                                                "domain": {"variable": "hydra.core.model.ApplicationType"},
                                                                                "body": {"application": {"function": {"variable": "reduceApp"}, "argument": {"variable": "a"}}}}}}]}},
                                                                    "argument": {"variable": "r"}}}}},
                                                            "typeScheme": {
                                                              "variables": [],
                                                              "body": {
                                                                "function": {
                                                                  "domain": {"variable": "hydra.core.model.Type"},
                                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
                                                              "constraints": []}}],
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {
                                                                        "body": {
                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                        "type": {"variable": "hydra.core.model.Type"}}},
                                                                    "type": {"variable": "hydra.core.model.Type"}}},
                                                                "argument": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "t"}}}}},
                                                            "argument": {
                                                              "lambda": {
                                                                "parameter": "r",
                                                                "domain": {"variable": "hydra.core.model.Type"},
                                                                "body": {"application": {"function": {"variable": "findApp"}, "argument": {"variable": "r"}}}}}}}}}}}}}}},
                                        "typeScheme": {
                                          "variables": ["t1"],
                                          "body": {
                                            "function": {
                                              "domain": {
                                                "function": {
                                                  "domain": {"variable": "t1"},
                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
                                              "codomain": {
                                                "function": {
                                                  "domain": {"variable": "t1"},
                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}}}},
                                          "constraints": []}}],
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.rewriting.rewriteTypeM"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                            "argument": {"typeApplication": {"body": {"variable": "mapExpr"}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                        "argument": {"variable": "typ"}}}}}}}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {"literal": {"string": "Eagerly beta-reduce a type by substituting type arguments into type lambdas"}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.contractTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Term"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "term",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "rewrite",
                        "term": {
                          "typeLambda": {
                            "parameter": "t0",
                            "body": {
                              "lambda": {
                                "parameter": "recurse",
                                "domain": {"function": {"domain": {"variable": "t0"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                "body": {
                                  "lambda": {
                                    "parameter": "t",
                                    "domain": {"variable": "t0"},
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "rec",
                                            "term": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "t"}}},
                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                        "body": {
                                          "application": {
                                            "function": {
                                              "cases": {
                                                "typeName": "hydra.core.model.Term",
                                                "default": {"variable": "rec"},
                                                "cases": [
                                                  {
                                                    "name": "application",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "app",
                                                        "domain": {"variable": "hydra.core.model.Application"},
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "lhs",
                                                                "term": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                                    "argument": {"variable": "app"}}},
                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "rhs",
                                                                    "term": {
                                                                      "application": {
                                                                        "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "argument"}},
                                                                        "argument": {"variable": "app"}}},
                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "cases": {
                                                                        "typeName": "hydra.core.model.Term",
                                                                        "default": {"variable": "rec"},
                                                                        "cases": [
                                                                          {
                                                                            "name": "lambda",
                                                                            "handler": {
                                                                              "lambda": {
                                                                                "parameter": "l",
                                                                                "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "v",
                                                                                        "term": {
                                                                                          "application": {
                                                                                            "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
                                                                                            "argument": {"variable": "l"}}},
                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                    "body": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "body",
                                                                                            "term": {
                                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}},
                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "hydra.core.variables.isFreeVariableInTerm"}, "argument": {"variable": "v"}}},
                                                                                                        "argument": {"variable": "body"}}}}},
                                                                                                "argument": {"variable": "body"}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {"function": {"variable": "hydra.core.variables.replaceFreeTermVariable"}, "argument": {"variable": "v"}}},
                                                                                                    "argument": {"variable": "rhs"}}},
                                                                                                "argument": {"variable": "body"}}}}}}}}}}}}]}},
                                                                    "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "lhs"}}}}}}}}}}}}]}},
                                            "argument": {"variable": "rec"}}}}}}}}}}},
                        "typeScheme": {
                          "variables": ["t0"],
                          "body": {
                            "function": {
                              "domain": {"function": {"domain": {"variable": "t0"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                              "codomain": {"function": {"domain": {"variable": "t0"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                          "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {"variable": "hydra.core.rewriting.rewriteTerm"},
                            "argument": {"typeApplication": {"body": {"variable": "rewrite"}, "type": {"variable": "hydra.core.model.Term"}}}}},
                        "argument": {"variable": "term"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Apply the special rules:\n    ((\\x.e1) e2) == e1, where x does not appear free in e1\n  and\n     ((\\x.e1) e2) = e1[x/e2]\nThese are both limited forms of beta reduction which help to \"clean up\" a term without fully evaluating it."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.countPrimitiveInvocations",
        "signature": {"typeParameters": [], "parameters": [], "result": {"type": {"literal": "boolean"}}},
        "body": {
          "annotated": {
            "body": {"literal": {"boolean": true}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Compile-time flag controlling whether primitive invocations are counted during evaluation. For demo and instrumentation purposes."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.etaExpandTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Term"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "tx0",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "term0",
                    "domain": {"variable": "hydra.core.model.Term"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "primTypes",
                            "term": {
                              "application": {
                                "function": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                    "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                "argument": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.graph.Primitive"}}},
                                            "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.TypeScheme"}}}}},
                                        "argument": {
                                          "lambda": {
                                            "parameter": "_gpt_p",
                                            "domain": {"variable": "hydra.core.graph.Primitive"},
                                            "body": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "pair": {
                                                        "first": {
                                                          "application": {
                                                            "function": {"project": {"typeName": "hydra.core.packaging.PrimitiveDefinition", "fieldName": "name"}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.graph.Primitive", "fieldName": "definition"}},
                                                                "argument": {"variable": "_gpt_p"}}}}},
                                                        "second": {
                                                          "application": {
                                                            "function": {"variable": "hydra.core.scoping.termSignatureToTypeScheme"},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.packaging.PrimitiveDefinition", "fieldName": "signature"}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.graph.Primitive", "fieldName": "definition"}},
                                                                    "argument": {"variable": "_gpt_p"}}}}}}}}},
                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                "type": {"variable": "hydra.core.model.TypeScheme"}}}}}}},
                                    "argument": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.elems"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "type": {"variable": "hydra.core.graph.Primitive"}}},
                                        "argument": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "primitives"}},
                                            "argument": {"variable": "tx0"}}}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                              "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "termArityWithContext",
                                "term": {
                                  "lambda": {
                                    "parameter": "tx",
                                    "domain": {"variable": "hydra.core.graph.Graph"},
                                    "body": {
                                      "lambda": {
                                        "parameter": "term",
                                        "domain": {"variable": "hydra.core.model.Term"},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "cases": {
                                                "typeName": "hydra.core.model.Term",
                                                "default": {"literal": {"integer": {"int32": 0}}},
                                                "cases": [
                                                  {
                                                    "name": "annotated",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "at",
                                                        "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                        "body": {
                                                          "application": {
                                                            "function": {"application": {"function": {"variable": "termArityWithContext"}, "argument": {"variable": "tx"}}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                "argument": {"variable": "at"}}}}}}}},
                                                  {
                                                    "name": "application",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "app",
                                                        "domain": {"variable": "hydra.core.model.Application"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.sub"}, "type": {"literal": {"integer": "int32"}}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"application": {"function": {"variable": "termArityWithContext"}, "argument": {"variable": "tx"}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                                        "argument": {"variable": "app"}}}}}}},
                                                            "argument": {"literal": {"integer": {"int32": 1}}}}}}}},
                                                  {
                                                    "name": "cases",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "_",
                                                        "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                        "body": {"literal": {"integer": {"int32": 1}}}}}},
                                                  {
                                                    "name": "lambda",
                                                    "handler": {
                                                      "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Lambda"}, "body": {"literal": {"integer": {"int32": 0}}}}}},
                                                  {
                                                    "name": "project",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "_",
                                                        "domain": {"variable": "hydra.core.model.Projection"},
                                                        "body": {"literal": {"integer": {"int32": 1}}}}}},
                                                  {
                                                    "name": "unwrap",
                                                    "handler": {
                                                      "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Name"}, "body": {"literal": {"integer": {"int32": 1}}}}}},
                                                  {
                                                    "name": "let",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "l",
                                                        "domain": {"variable": "hydra.core.model.Let"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {"variable": "termArityWithContext"},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {"variable": "hydra.core.scoping.extendGraphForLet"},
                                                                            "argument": {
                                                                              "lambda": {
                                                                                "parameter": "_",
                                                                                "domain": {"variable": "hydra.core.graph.Graph"},
                                                                                "body": {
                                                                                  "lambda": {
                                                                                    "parameter": "_",
                                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                                    "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                        "argument": {"variable": "tx"}}},
                                                                    "argument": {"variable": "l"}}}}},
                                                            "argument": {
                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}}},
                                                  {
                                                    "name": "typeLambda",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "tl",
                                                        "domain": {"variable": "hydra.core.model.TypeLambda"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {"variable": "termArityWithContext"},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {"function": {"variable": "hydra.core.scoping.extendGraphForTypeLambda"}, "argument": {"variable": "tx"}}},
                                                                    "argument": {"variable": "tl"}}}}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "body"}},
                                                                "argument": {"variable": "tl"}}}}}}}},
                                                  {
                                                    "name": "typeApplication",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "tat",
                                                        "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                        "body": {
                                                          "application": {
                                                            "function": {"application": {"function": {"variable": "termArityWithContext"}, "argument": {"variable": "tx"}}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                "argument": {"variable": "tat"}}}}}}}},
                                                  {
                                                    "name": "variable",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "name",
                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "typeApplication": {
                                                                        "body": {
                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                        "type": {"literal": {"integer": "int32"}}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                "type": {"variable": "hydra.core.model.Type"}}},
                                                                            "argument": {"variable": "hydra.core.scoping.typeSchemeToFType"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {
                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                "argument": {"variable": "name"}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
                                                                                "argument": {"variable": "tx"}}}}}}}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                "type": {"literal": {"integer": "int32"}}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {
                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                        "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                    "argument": {"variable": "name"}}},
                                                                                "argument": {"variable": "primTypes"}}}}},
                                                                        "argument": {"literal": {"integer": {"int32": 0}}}}},
                                                                    "argument": {"variable": "hydra.core.arity.typeSchemeArity"}}}}},
                                                            "argument": {"variable": "hydra.core.arity.typeArity"}}}}}}]}},
                                            "argument": {"variable": "term"}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {
                                    "function": {
                                      "domain": {"variable": "hydra.core.graph.Graph"},
                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"literal": {"integer": "int32"}}}}}},
                                  "constraints": []}}],
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "domainTypes",
                                    "term": {
                                      "lambda": {
                                        "parameter": "n",
                                        "domain": {"literal": {"integer": "int32"}},
                                        "body": {
                                          "lambda": {
                                            "parameter": "mt",
                                            "domain": {"optional": {"variable": "hydra.core.model.Type"}},
                                            "body": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                            "type": {"list": {"optional": {"variable": "hydra.core.model.Type"}}}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.lte"}, "type": {"literal": {"integer": "int32"}}}},
                                                                "argument": {"variable": "n"}}},
                                                            "argument": {"literal": {"integer": {"int32": 0}}}}}}},
                                                    "argument": {"typeApplication": {"body": {"list": []}, "type": {"optional": {"variable": "hydra.core.model.Type"}}}}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                "type": {"list": {"optional": {"variable": "hydra.core.model.Type"}}}}},
                                                            "argument": {"variable": "mt"}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"literal": {"integer": "int32"}}}},
                                                                    "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                "argument": {
                                                                  "lambda": {
                                                                    "parameter": "_",
                                                                    "domain": {"literal": {"integer": "int32"}},
                                                                    "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}}}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {"function": {"variable": "hydra.core.lib.math.range"}, "argument": {"literal": {"integer": {"int32": 0}}}}},
                                                                "argument": {"variable": "n"}}}}}}},
                                                    "argument": {
                                                      "lambda": {
                                                        "parameter": "typ",
                                                        "domain": {"variable": "hydra.core.model.Type"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "cases": {
                                                                "typeName": "hydra.core.model.Type",
                                                                "default": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"literal": {"integer": "int32"}}}},
                                                                            "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                        "argument": {
                                                                          "lambda": {
                                                                            "parameter": "_",
                                                                            "domain": {"literal": {"integer": "int32"}},
                                                                            "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {"function": {"variable": "hydra.core.lib.math.range"}, "argument": {"literal": {"integer": {"int32": 0}}}}},
                                                                        "argument": {"variable": "n"}}}}},
                                                                "cases": [
                                                                  {
                                                                    "name": "function",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "ftyp",
                                                                        "domain": {"variable": "hydra.core.model.FunctionType"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                                "argument": {
                                                                                  "optional": {
                                                                                    "application": {
                                                                                      "function": {"project": {"typeName": "hydra.core.model.FunctionType", "fieldName": "domain"}},
                                                                                      "argument": {"variable": "ftyp"}}}}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"variable": "domainTypes"},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.sub"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                            "argument": {"variable": "n"}}},
                                                                                        "argument": {"literal": {"integer": {"int32": 1}}}}}}},
                                                                                "argument": {
                                                                                  "optional": {
                                                                                    "application": {
                                                                                      "function": {"project": {"typeName": "hydra.core.model.FunctionType", "fieldName": "codomain"}},
                                                                                      "argument": {"variable": "ftyp"}}}}}}}}}}},
                                                                  {
                                                                    "name": "annotated",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "at",
                                                                        "domain": {"variable": "hydra.core.model.AnnotatedType"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {"application": {"function": {"variable": "domainTypes"}, "argument": {"variable": "n"}}},
                                                                            "argument": {
                                                                              "optional": {
                                                                                "application": {
                                                                                  "function": {"project": {"typeName": "hydra.core.model.AnnotatedType", "fieldName": "body"}},
                                                                                  "argument": {"variable": "at"}}}}}}}}},
                                                                  {
                                                                    "name": "application",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "atyp",
                                                                        "domain": {"variable": "hydra.core.model.ApplicationType"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {"application": {"function": {"variable": "domainTypes"}, "argument": {"variable": "n"}}},
                                                                            "argument": {
                                                                              "optional": {
                                                                                "application": {
                                                                                  "function": {"project": {"typeName": "hydra.core.model.ApplicationType", "fieldName": "function"}},
                                                                                  "argument": {"variable": "atyp"}}}}}}}}},
                                                                  {
                                                                    "name": "forall",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "_",
                                                                        "domain": {"variable": "hydra.core.model.ForallType"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {
                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                    "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                                "argument": {
                                                                                  "lambda": {
                                                                                    "parameter": "_",
                                                                                    "domain": {"literal": {"integer": "int32"}},
                                                                                    "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {"function": {"variable": "hydra.core.lib.math.range"}, "argument": {"literal": {"integer": {"int32": 0}}}}},
                                                                                "argument": {"variable": "n"}}}}}}}}]}},
                                                            "argument": {"variable": "typ"}}}}}}}}}}}}},
                                    "typeScheme": {
                                      "variables": [],
                                      "body": {
                                        "function": {
                                          "domain": {"literal": {"integer": "int32"}},
                                          "codomain": {
                                            "function": {
                                              "domain": {"optional": {"variable": "hydra.core.model.Type"}},
                                              "codomain": {"list": {"optional": {"variable": "hydra.core.model.Type"}}}}}}},
                                      "constraints": []}}],
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "peelFunctionDomains",
                                        "term": {
                                          "lambda": {
                                            "parameter": "mtyp",
                                            "domain": {"optional": {"variable": "hydra.core.model.Type"}},
                                            "body": {
                                              "lambda": {
                                                "parameter": "n",
                                                "domain": {"literal": {"integer": "int32"}},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.lte"}, "type": {"literal": {"integer": "int32"}}}},
                                                                    "argument": {"variable": "n"}}},
                                                                "argument": {"literal": {"integer": {"int32": 0}}}}}}},
                                                        "argument": {"variable": "mtyp"}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                    "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                "argument": {"variable": "mtyp"}}},
                                                            "argument": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                        "argument": {
                                                          "lambda": {
                                                            "parameter": "typ",
                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "cases": {
                                                                    "typeName": "hydra.core.model.Type",
                                                                    "default": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                    "cases": [
                                                                      {
                                                                        "name": "function",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "ftyp",
                                                                            "domain": {"variable": "hydra.core.model.FunctionType"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"variable": "peelFunctionDomains"},
                                                                                    "argument": {
                                                                                      "optional": {
                                                                                        "application": {
                                                                                          "function": {"project": {"typeName": "hydra.core.model.FunctionType", "fieldName": "codomain"}},
                                                                                          "argument": {"variable": "ftyp"}}}}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.sub"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                        "argument": {"variable": "n"}}},
                                                                                    "argument": {"literal": {"integer": {"int32": 1}}}}}}}}}},
                                                                      {
                                                                        "name": "annotated",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "at",
                                                                            "domain": {"variable": "hydra.core.model.AnnotatedType"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"variable": "peelFunctionDomains"},
                                                                                    "argument": {
                                                                                      "optional": {
                                                                                        "application": {
                                                                                          "function": {"project": {"typeName": "hydra.core.model.AnnotatedType", "fieldName": "body"}},
                                                                                          "argument": {"variable": "at"}}}}}},
                                                                                "argument": {"variable": "n"}}}}}},
                                                                      {
                                                                        "name": "application",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "atyp",
                                                                            "domain": {"variable": "hydra.core.model.ApplicationType"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"variable": "peelFunctionDomains"},
                                                                                    "argument": {
                                                                                      "optional": {
                                                                                        "application": {
                                                                                          "function": {"project": {"typeName": "hydra.core.model.ApplicationType", "fieldName": "function"}},
                                                                                          "argument": {"variable": "atyp"}}}}}},
                                                                                "argument": {"variable": "n"}}}}}},
                                                                      {
                                                                        "name": "forall",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "_",
                                                                            "domain": {"variable": "hydra.core.model.ForallType"},
                                                                            "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}}}]}},
                                                                "argument": {"variable": "typ"}}}}}}}}}}}}},
                                        "typeScheme": {
                                          "variables": [],
                                          "body": {
                                            "function": {
                                              "domain": {"optional": {"variable": "hydra.core.model.Type"}},
                                              "codomain": {
                                                "function": {"domain": {"literal": {"integer": "int32"}}, "codomain": {"optional": {"variable": "hydra.core.model.Type"}}}}}},
                                          "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "expand",
                                            "term": {
                                              "lambda": {
                                                "parameter": "alwaysPad",
                                                "domain": {"literal": "boolean"},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "args",
                                                    "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "arity",
                                                        "domain": {"literal": {"integer": "int32"}},
                                                        "body": {
                                                          "lambda": {
                                                            "parameter": "headTyp",
                                                            "domain": {"optional": {"variable": "hydra.core.model.Type"}},
                                                            "body": {
                                                              "lambda": {
                                                                "parameter": "head",
                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "applied",
                                                                        "term": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {
                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                    "argument": {
                                                                                      "lambda": {
                                                                                        "parameter": "lhs",
                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                        "body": {
                                                                                          "lambda": {
                                                                                            "parameter": "arg",
                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                            "body": {
                                                                                              "inject": {
                                                                                                "typeName": "hydra.core.model.Term",
                                                                                                "field": {
                                                                                                  "name": "application",
                                                                                                  "term": {
                                                                                                    "record": {
                                                                                                      "typeName": "hydra.core.model.Application",
                                                                                                      "fields": [{"name": "function", "term": {"variable": "lhs"}}, {"name": "argument", "term": {"variable": "arg"}}]}}}}}}}}}}},
                                                                                "argument": {"variable": "head"}}},
                                                                            "argument": {"variable": "args"}}},
                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "numArgs",
                                                                            "term": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                "argument": {"variable": "args"}}},
                                                                            "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "needed",
                                                                                "term": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.sub"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                        "argument": {"variable": "arity"}}},
                                                                                    "argument": {"variable": "numArgs"}}},
                                                                                "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {"variable": "hydra.core.lib.logic.and"},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.gt"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                        "argument": {"variable": "needed"}}},
                                                                                                    "argument": {"literal": {"integer": {"int32": 0}}}}}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "hydra.core.lib.logic.or"}, "argument": {"variable": "alwaysPad"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.gt"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                        "argument": {"variable": "numArgs"}}},
                                                                                                    "argument": {"literal": {"integer": {"int32": 0}}}}}}}}}}},
                                                                                    "argument": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "indices",
                                                                                            "term": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {"function": {"variable": "hydra.core.lib.math.range"}, "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.add"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                        "argument": {"variable": "needed"}}},
                                                                                                    "argument": {"literal": {"integer": {"int32": 1}}}}}}},
                                                                                            "typeScheme": {"variables": [], "body": {"list": {"literal": {"integer": "int32"}}}, "constraints": []}}],
                                                                                        "body": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "remainingType",
                                                                                                "term": {
                                                                                                  "application": {
                                                                                                    "function": {"application": {"function": {"variable": "peelFunctionDomains"}, "argument": {"variable": "headTyp"}}},
                                                                                                    "argument": {"variable": "numArgs"}}},
                                                                                                "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "domains",
                                                                                                    "term": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "domainTypes"}, "argument": {"variable": "needed"}}},
                                                                                                        "argument": {"variable": "remainingType"}}},
                                                                                                    "typeScheme": {"variables": [], "body": {"list": {"optional": {"variable": "hydra.core.model.Type"}}}, "constraints": []}}],
                                                                                                "body": {
                                                                                                  "let": {
                                                                                                    "bindings": [
                                                                                                      {
                                                                                                        "name": "codomainType",
                                                                                                        "term": {
                                                                                                          "application": {
                                                                                                            "function": {"application": {"function": {"variable": "peelFunctionDomains"}, "argument": {"variable": "remainingType"}}},
                                                                                                            "argument": {"variable": "needed"}}},
                                                                                                        "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "fullyAppliedRaw",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "type": {"literal": {"integer": "int32"}}}},
                                                                                                                        "argument": {
                                                                                                                          "lambda": {
                                                                                                                            "parameter": "body",
                                                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                            "body": {
                                                                                                                              "lambda": {
                                                                                                                                "parameter": "i",
                                                                                                                                "domain": {"literal": {"integer": "int32"}},
                                                                                                                                "body": {
                                                                                                                                  "let": {
                                                                                                                                    "bindings": [
                                                                                                                                      {
                                                                                                                                        "name": "vn",
                                                                                                                                        "term": {
                                                                                                                                          "wrap": {
                                                                                                                                            "typeName": "hydra.core.model.Name",
                                                                                                                                            "body": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {"application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "v"}}}},
                                                                                                                                                "argument": {"application": {"function": {"variable": "hydra.core.lib.literals.printInt32"}, "argument": {"variable": "i"}}}}}}},
                                                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                                                                    "body": {
                                                                                                                                      "inject": {
                                                                                                                                        "typeName": "hydra.core.model.Term",
                                                                                                                                        "field": {
                                                                                                                                          "name": "application",
                                                                                                                                          "term": {
                                                                                                                                            "record": {
                                                                                                                                              "typeName": "hydra.core.model.Application",
                                                                                                                                              "fields": [
                                                                                                                                                {"name": "function", "term": {"variable": "body"}},
                                                                                                                                                {
                                                                                                                                                  "name": "argument",
                                                                                                                                                  "term": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "variable", "term": {"variable": "vn"}}}}}]}}}}}}}}}}}}},
                                                                                                                    "argument": {"variable": "applied"}}},
                                                                                                                "argument": {"variable": "indices"}}},
                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "let": {
                                                                                                            "bindings": [
                                                                                                              {
                                                                                                                "name": "fullyApplied",
                                                                                                                "term": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "argument": {"variable": "codomainType"}}},
                                                                                                                        "argument": {"variable": "fullyAppliedRaw"}}},
                                                                                                                    "argument": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "ct",
                                                                                                                        "domain": {"variable": "hydra.core.model.Type"},
                                                                                                                        "body": {
                                                                                                                          "inject": {
                                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                                            "field": {
                                                                                                                              "name": "annotated",
                                                                                                                              "term": {
                                                                                                                                "record": {
                                                                                                                                  "typeName": "hydra.core.model.AnnotatedTerm",
                                                                                                                                  "fields": [
                                                                                                                                    {"name": "body", "term": {"variable": "fullyAppliedRaw"}},
                                                                                                                                    {
                                                                                                                                      "name": "annotation",
                                                                                                                                      "term": {
                                                                                                                                        "application": {
                                                                                                                                          "function": {"variable": "hydra.core.annotations.wrapAnnotationMap"},
                                                                                                                                          "argument": {
                                                                                                                                            "application": {
                                                                                                                                              "function": {
                                                                                                                                                "application": {
                                                                                                                                                  "function": {
                                                                                                                                                    "typeApplication": {
                                                                                                                                                      "body": {
                                                                                                                                                        "typeApplication": {"body": {"variable": "hydra.core.lib.maps.singleton"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                      "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                  "argument": {"wrap": {"typeName": "hydra.core.model.Name", "body": {"literal": {"string": "type"}}}}}},
                                                                                                                                              "argument": {"application": {"function": {"variable": "hydra.core.encode.model.type"}, "argument": {"variable": "ct"}}}}}}}}]}}}}}}}}},
                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                            "body": {
                                                                                                              "let": {
                                                                                                                "bindings": [
                                                                                                                  {
                                                                                                                    "name": "indexedDomains",
                                                                                                                    "term": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.zip"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                            "argument": {"variable": "indices"}}},
                                                                                                                        "argument": {"variable": "domains"}}},
                                                                                                                    "typeScheme": {
                                                                                                                      "variables": [],
                                                                                                                      "body": {
                                                                                                                        "list": {"pair": {"first": {"literal": {"integer": "int32"}}, "second": {"optional": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                                      "constraints": []}}],
                                                                                                                "body": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"pair": {"first": {"literal": {"integer": "int32"}}, "second": {"optional": {"variable": "hydra.core.model.Type"}}}}}},
                                                                                                                            "argument": {
                                                                                                                              "lambda": {
                                                                                                                                "parameter": "body",
                                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                "body": {
                                                                                                                                  "lambda": {
                                                                                                                                    "parameter": "idPair",
                                                                                                                                    "domain": {"pair": {"first": {"literal": {"integer": "int32"}}, "second": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                                    "body": {
                                                                                                                                      "let": {
                                                                                                                                        "bindings": [
                                                                                                                                          {
                                                                                                                                            "name": "i",
                                                                                                                                            "term": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                    "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                                                "argument": {"variable": "idPair"}}},
                                                                                                                                            "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                                                                                        "body": {
                                                                                                                                          "let": {
                                                                                                                                            "bindings": [
                                                                                                                                              {
                                                                                                                                                "name": "dom",
                                                                                                                                                "term": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                        "type": {"optional": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                                                    "argument": {"variable": "idPair"}}},
                                                                                                                                                "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                                                                            "body": {
                                                                                                                                              "let": {
                                                                                                                                                "bindings": [
                                                                                                                                                  {
                                                                                                                                                    "name": "vn",
                                                                                                                                                    "term": {
                                                                                                                                                      "wrap": {
                                                                                                                                                        "typeName": "hydra.core.model.Name",
                                                                                                                                                        "body": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {"application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "v"}}}},
                                                                                                                                                            "argument": {"application": {"function": {"variable": "hydra.core.lib.literals.printInt32"}, "argument": {"variable": "i"}}}}}}},
                                                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                                                                                "body": {
                                                                                                                                                  "inject": {
                                                                                                                                                    "typeName": "hydra.core.model.Term",
                                                                                                                                                    "field": {
                                                                                                                                                      "name": "lambda",
                                                                                                                                                      "term": {
                                                                                                                                                        "record": {
                                                                                                                                                          "typeName": "hydra.core.model.Lambda",
                                                                                                                                                          "fields": [
                                                                                                                                                            {"name": "parameter", "term": {"variable": "vn"}},
                                                                                                                                                            {"name": "domain", "term": {"variable": "dom"}},
                                                                                                                                                            {"name": "body", "term": {"variable": "body"}}]}}}}}}}}}}}}}}}}},
                                                                                                                        "argument": {"variable": "fullyApplied"}}},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {"variable": "hydra.core.lib.lists.reverse"},
                                                                                                                            "type": {"pair": {"first": {"literal": {"integer": "int32"}}, "second": {"optional": {"variable": "hydra.core.model.Type"}}}}}},
                                                                                                                        "argument": {"variable": "indexedDomains"}}}}}}}}}}}}}}}}}}}}},
                                                                                "argument": {"variable": "applied"}}}}}}}}}}}}}}}}}}},
                                            "typeScheme": {
                                              "variables": [],
                                              "body": {
                                                "function": {
                                                  "domain": {"literal": "boolean"},
                                                  "codomain": {
                                                    "function": {
                                                      "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                      "codomain": {
                                                        "function": {
                                                          "domain": {"literal": {"integer": "int32"}},
                                                          "codomain": {
                                                            "function": {
                                                              "domain": {"optional": {"variable": "hydra.core.model.Type"}},
                                                              "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}}}}}}}},
                                              "constraints": []}}],
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "rewriteWithArgs",
                                                "term": {
                                                  "lambda": {
                                                    "parameter": "args",
                                                    "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "tx",
                                                        "domain": {"variable": "hydra.core.graph.Graph"},
                                                        "body": {
                                                          "lambda": {
                                                            "parameter": "term",
                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "recurse",
                                                                    "term": {
                                                                      "lambda": {
                                                                        "parameter": "tx1",
                                                                        "domain": {"variable": "hydra.core.graph.Graph"},
                                                                        "body": {
                                                                          "lambda": {
                                                                            "parameter": "term1",
                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {"variable": "rewriteWithArgs"},
                                                                                        "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                    "argument": {"variable": "tx1"}}},
                                                                                "argument": {"variable": "term1"}}}}}}},
                                                                    "typeScheme": {
                                                                      "variables": [],
                                                                      "body": {
                                                                        "function": {
                                                                          "domain": {"variable": "hydra.core.graph.Graph"},
                                                                          "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                                                      "constraints": []}}],
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "termHeadType",
                                                                        "term": {
                                                                          "lambda": {
                                                                            "parameter": "tx2",
                                                                            "domain": {"variable": "hydra.core.graph.Graph"},
                                                                            "body": {
                                                                              "lambda": {
                                                                                "parameter": "trm2",
                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "cases": {
                                                                                        "typeName": "hydra.core.model.Term",
                                                                                        "default": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                        "cases": [
                                                                                          {
                                                                                            "name": "annotated",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "at2",
                                                                                                "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {"application": {"function": {"variable": "termHeadType"}, "argument": {"variable": "tx2"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                                                        "argument": {"variable": "at2"}}}}}}}},
                                                                                          {
                                                                                            "name": "lambda",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "_",
                                                                                                "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                                "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}}},
                                                                                          {
                                                                                            "name": "cases",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "_",
                                                                                                "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}}},
                                                                                          {
                                                                                            "name": "project",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "_",
                                                                                                "domain": {"variable": "hydra.core.model.Projection"},
                                                                                                "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}}},
                                                                                          {
                                                                                            "name": "unwrap",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "_",
                                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                                "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}}},
                                                                                          {
                                                                                            "name": "let",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "l2",
                                                                                                "domain": {"variable": "hydra.core.model.Let"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "termHeadType"},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "hydra.core.scoping.extendGraphForLet"},
                                                                                                                    "argument": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "_",
                                                                                                                        "domain": {"variable": "hydra.core.graph.Graph"},
                                                                                                                        "body": {
                                                                                                                          "lambda": {
                                                                                                                            "parameter": "_",
                                                                                                                            "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                            "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                                                                "argument": {"variable": "tx2"}}},
                                                                                                            "argument": {"variable": "l2"}}}}},
                                                                                                    "argument": {
                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l2"}}}}}}}},
                                                                                          {
                                                                                            "name": "typeLambda",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "tl2",
                                                                                                "domain": {"variable": "hydra.core.model.TypeLambda"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "termHeadType"},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {"function": {"variable": "hydra.core.scoping.extendGraphForTypeLambda"}, "argument": {"variable": "tx2"}}},
                                                                                                            "argument": {"variable": "tl2"}}}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "body"}},
                                                                                                        "argument": {"variable": "tl2"}}}}}}}},
                                                                                          {
                                                                                            "name": "typeApplication",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "tat2",
                                                                                                "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.bind"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {"application": {"function": {"variable": "termHeadType"}, "argument": {"variable": "tx2"}}},
                                                                                                            "argument": {
                                                                                                              "application": {
                                                                                                                "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                                                                "argument": {"variable": "tat2"}}}}}}},
                                                                                                    "argument": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "htyp2",
                                                                                                        "domain": {"variable": "hydra.core.model.Type"},
                                                                                                        "body": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "cases": {
                                                                                                                "typeName": "hydra.core.model.Type",
                                                                                                                "default": {"optional": {"variable": "htyp2"}},
                                                                                                                "cases": [
                                                                                                                  {
                                                                                                                    "name": "forall",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "ft2",
                                                                                                                        "domain": {"variable": "hydra.core.model.ForallType"},
                                                                                                                        "body": {
                                                                                                                          "optional": {
                                                                                                                            "application": {
                                                                                                                              "function": {
                                                                                                                                "application": {
                                                                                                                                  "function": {
                                                                                                                                    "application": {
                                                                                                                                      "function": {"variable": "hydra.core.variables.replaceFreeTypeVariable"},
                                                                                                                                      "argument": {
                                                                                                                                        "application": {
                                                                                                                                          "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
                                                                                                                                          "argument": {"variable": "ft2"}}}}},
                                                                                                                                  "argument": {
                                                                                                                                    "application": {
                                                                                                                                      "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
                                                                                                                                      "argument": {"variable": "tat2"}}}}},
                                                                                                                              "argument": {
                                                                                                                                "application": {
                                                                                                                                  "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "body"}},
                                                                                                                                  "argument": {"variable": "ft2"}}}}}}}}}]}},
                                                                                                            "argument": {"variable": "htyp2"}}}}}}}}}},
                                                                                          {
                                                                                            "name": "variable",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "vn2",
                                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                        "argument": {"variable": "hydra.core.scoping.typeSchemeToFType"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                            "argument": {"variable": "vn2"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
                                                                                                            "argument": {"variable": "tx2"}}}}}}}}}}]}},
                                                                                    "argument": {"variable": "trm2"}}}}}}},
                                                                        "typeScheme": {
                                                                          "variables": [],
                                                                          "body": {
                                                                            "function": {
                                                                              "domain": {"variable": "hydra.core.graph.Graph"},
                                                                              "codomain": {
                                                                                "function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"optional": {"variable": "hydra.core.model.Type"}}}}}},
                                                                          "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "afterRecursion",
                                                                            "term": {
                                                                              "lambda": {
                                                                                "parameter": "trm",
                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "arity",
                                                                                        "term": {
                                                                                          "application": {
                                                                                            "function": {"application": {"function": {"variable": "termArityWithContext"}, "argument": {"variable": "tx"}}},
                                                                                            "argument": {"variable": "trm"}}},
                                                                                        "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                                    "body": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "hType",
                                                                                            "term": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "termHeadType"}, "argument": {"variable": "tx"}}},
                                                                                                "argument": {"variable": "trm"}}},
                                                                                            "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "expand"}, "argument": {"literal": {"boolean": false}}}},
                                                                                                        "argument": {"variable": "args"}}},
                                                                                                    "argument": {"variable": "arity"}}},
                                                                                                "argument": {"variable": "hType"}}},
                                                                                            "argument": {"variable": "trm"}}}}}}}}},
                                                                            "typeScheme": {
                                                                              "variables": [],
                                                                              "body": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                                                              "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "forField",
                                                                                "term": {
                                                                                  "lambda": {
                                                                                    "parameter": "f",
                                                                                    "domain": {"variable": "hydra.core.model.Field"},
                                                                                    "body": {
                                                                                      "record": {
                                                                                        "typeName": "hydra.core.model.Field",
                                                                                        "fields": [
                                                                                          {
                                                                                            "name": "name",
                                                                                            "term": {
                                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "name"}}, "argument": {"variable": "f"}}}},
                                                                                          {
                                                                                            "name": "term",
                                                                                            "term": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                "argument": {
                                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "term"}}, "argument": {"variable": "f"}}}}}}]}}}},
                                                                                "typeScheme": {
                                                                                  "variables": [],
                                                                                  "body": {"function": {"domain": {"variable": "hydra.core.model.Field"}, "codomain": {"variable": "hydra.core.model.Field"}}},
                                                                                  "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "forCaseBranch",
                                                                                    "term": {
                                                                                      "lambda": {
                                                                                        "parameter": "f",
                                                                                        "domain": {"variable": "hydra.core.model.CaseAlternative"},
                                                                                        "body": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "branchBody",
                                                                                                "term": {
                                                                                                  "application": {
                                                                                                    "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.CaseAlternative", "fieldName": "handler"}},
                                                                                                        "argument": {"variable": "f"}}}}},
                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "arty",
                                                                                                    "term": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "termArityWithContext"}, "argument": {"variable": "tx"}}},
                                                                                                        "argument": {"variable": "branchBody"}}},
                                                                                                    "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                                                "body": {
                                                                                                  "let": {
                                                                                                    "bindings": [
                                                                                                      {
                                                                                                        "name": "branchHType",
                                                                                                        "term": {
                                                                                                          "application": {
                                                                                                            "function": {"application": {"function": {"variable": "termHeadType"}, "argument": {"variable": "tx"}}},
                                                                                                            "argument": {"variable": "branchBody"}}},
                                                                                                        "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "record": {
                                                                                                        "typeName": "hydra.core.model.CaseAlternative",
                                                                                                        "fields": [
                                                                                                          {
                                                                                                            "name": "name",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {"project": {"typeName": "hydra.core.model.CaseAlternative", "fieldName": "name"}},
                                                                                                                "argument": {"variable": "f"}}}},
                                                                                                          {
                                                                                                            "name": "handler",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {"application": {"function": {"variable": "expand"}, "argument": {"literal": {"boolean": true}}}},
                                                                                                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                        "argument": {"variable": "arty"}}},
                                                                                                                    "argument": {"variable": "branchHType"}}},
                                                                                                                "argument": {"variable": "branchBody"}}}}]}}}}}}}}}},
                                                                                    "typeScheme": {
                                                                                      "variables": [],
                                                                                      "body": {
                                                                                        "function": {
                                                                                          "domain": {"variable": "hydra.core.model.CaseAlternative"},
                                                                                          "codomain": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                      "constraints": []}}],
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "forMap",
                                                                                        "term": {
                                                                                          "lambda": {
                                                                                            "parameter": "mp",
                                                                                            "domain": {"map": {"keys": {"variable": "hydra.core.model.Term"}, "values": {"variable": "hydra.core.model.Term"}}},
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "forPair",
                                                                                                    "term": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "pr",
                                                                                                        "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"variable": "hydra.core.model.Term"}}},
                                                                                                        "body": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "pair": {
                                                                                                                    "first": {
                                                                                                                      "application": {
                                                                                                                        "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "argument": {"variable": "pr"}}}}},
                                                                                                                    "second": {
                                                                                                                      "application": {
                                                                                                                        "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "argument": {"variable": "pr"}}}}}}},
                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                    "typeScheme": {
                                                                                                      "variables": [],
                                                                                                      "body": {
                                                                                                        "function": {
                                                                                                          "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"variable": "hydra.core.model.Term"}}},
                                                                                                          "codomain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                      "constraints": []}}],
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {"variable": "hydra.core.lib.lists.map"},
                                                                                                                    "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                            "argument": {"variable": "forPair"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.toList"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                            "argument": {"variable": "mp"}}}}}}}}}}},
                                                                                        "typeScheme": {
                                                                                          "variables": [],
                                                                                          "body": {
                                                                                            "function": {
                                                                                              "domain": {"map": {"keys": {"variable": "hydra.core.model.Term"}, "values": {"variable": "hydra.core.model.Term"}}},
                                                                                              "codomain": {"map": {"keys": {"variable": "hydra.core.model.Term"}, "values": {"variable": "hydra.core.model.Term"}}}}},
                                                                                          "constraints": []}}],
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "cases": {
                                                                                            "typeName": "hydra.core.model.Term",
                                                                                            "cases": [
                                                                                              {
                                                                                                "name": "annotated",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "at",
                                                                                                    "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "annotated",
                                                                                                              "term": {
                                                                                                                "record": {
                                                                                                                  "typeName": "hydra.core.model.AnnotatedTerm",
                                                                                                                  "fields": [
                                                                                                                    {
                                                                                                                      "name": "body",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                          "argument": {
                                                                                                                            "application": {
                                                                                                                              "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                                                                              "argument": {"variable": "at"}}}}}},
                                                                                                                    {
                                                                                                                      "name": "annotation",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "annotation"}},
                                                                                                                          "argument": {"variable": "at"}}}}]}}}}}}}}}},
                                                                                              {
                                                                                                "name": "application",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "app",
                                                                                                    "domain": {"variable": "hydra.core.model.Application"},
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "rhs",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {"variable": "rewriteWithArgs"},
                                                                                                                        "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                    "argument": {"variable": "tx"}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "argument"}},
                                                                                                                    "argument": {"variable": "app"}}}}},
                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "rewriteWithArgs"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "argument": {"variable": "rhs"}}},
                                                                                                                        "argument": {"variable": "args"}}}}},
                                                                                                                "argument": {"variable": "tx"}}},
                                                                                                            "argument": {
                                                                                                              "application": {
                                                                                                                "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                                                                                "argument": {"variable": "app"}}}}}}}}}},
                                                                                              {
                                                                                                "name": "either",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "e",
                                                                                                    "domain": {"either": {"left": {"variable": "hydra.core.model.Term"}, "right": {"variable": "hydra.core.model.Term"}}},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "either",
                                                                                                              "term": {
                                                                                                                "application": {
                                                                                                                  "function": {
                                                                                                                    "application": {
                                                                                                                      "function": {
                                                                                                                        "application": {
                                                                                                                          "function": {
                                                                                                                            "typeApplication": {
                                                                                                                              "body": {
                                                                                                                                "typeApplication": {
                                                                                                                                  "body": {
                                                                                                                                    "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.either"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                  "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                              "type": {"either": {"left": {"variable": "hydra.core.model.Term"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                          "argument": {
                                                                                                                            "lambda": {
                                                                                                                              "parameter": "l",
                                                                                                                              "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                              "body": {
                                                                                                                                "typeApplication": {
                                                                                                                                  "body": {
                                                                                                                                    "typeApplication": {
                                                                                                                                      "body": {
                                                                                                                                        "either": {
                                                                                                                                          "left": {
                                                                                                                                            "application": {
                                                                                                                                              "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                                              "argument": {"variable": "l"}}}}},
                                                                                                                                      "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                  "type": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                                                                      "argument": {
                                                                                                                        "lambda": {
                                                                                                                          "parameter": "r",
                                                                                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                          "body": {
                                                                                                                            "typeApplication": {
                                                                                                                              "body": {
                                                                                                                                "typeApplication": {
                                                                                                                                  "body": {
                                                                                                                                    "either": {
                                                                                                                                      "right": {
                                                                                                                                        "application": {
                                                                                                                                          "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                                          "argument": {"variable": "r"}}}}},
                                                                                                                                  "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                              "type": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                                                                  "argument": {"variable": "e"}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "cases",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "cs",
                                                                                                    "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "newCs",
                                                                                                            "term": {
                                                                                                              "record": {
                                                                                                                "typeName": "hydra.core.model.CaseStatement",
                                                                                                                "fields": [
                                                                                                                  {
                                                                                                                    "name": "typeName",
                                                                                                                    "term": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "typeName"}},
                                                                                                                        "argument": {"variable": "cs"}}}},
                                                                                                                  {
                                                                                                                    "name": "default",
                                                                                                                    "term": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "argument": {
                                                                                                                              "lambda": {
                                                                                                                                "parameter": "t1",
                                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                "body": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                                    "argument": {"variable": "t1"}}}}}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "default"}},
                                                                                                                            "argument": {"variable": "cs"}}}}}},
                                                                                                                  {
                                                                                                                    "name": "cases",
                                                                                                                    "term": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                                                "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                                            "argument": {"variable": "forCaseBranch"}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "cases"}},
                                                                                                                            "argument": {"variable": "cs"}}}}}}]}},
                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.CaseStatement"}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "let": {
                                                                                                            "bindings": [
                                                                                                              {
                                                                                                                "name": "elimTerm",
                                                                                                                "term": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "cases", "term": {"variable": "newCs"}}}},
                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                            "body": {
                                                                                                              "let": {
                                                                                                                "bindings": [
                                                                                                                  {
                                                                                                                    "name": "elimHeadType",
                                                                                                                    "term": {
                                                                                                                      "optional": {
                                                                                                                        "inject": {
                                                                                                                          "typeName": "hydra.core.model.Type",
                                                                                                                          "field": {
                                                                                                                            "name": "function",
                                                                                                                            "term": {
                                                                                                                              "record": {
                                                                                                                                "typeName": "hydra.core.model.FunctionType",
                                                                                                                                "fields": [
                                                                                                                                  {
                                                                                                                                    "name": "domain",
                                                                                                                                    "term": {
                                                                                                                                      "inject": {
                                                                                                                                        "typeName": "hydra.core.model.Type",
                                                                                                                                        "field": {
                                                                                                                                          "name": "variable",
                                                                                                                                          "term": {
                                                                                                                                            "application": {
                                                                                                                                              "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "typeName"}},
                                                                                                                                              "argument": {"variable": "cs"}}}}}}},
                                                                                                                                  {
                                                                                                                                    "name": "codomain",
                                                                                                                                    "term": {"inject": {"typeName": "hydra.core.model.Type", "field": {"name": "unit", "term": "unit"}}}}]}}}}}},
                                                                                                                    "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                                                "body": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "expand"}, "argument": {"literal": {"boolean": true}}}},
                                                                                                                                "argument": {"variable": "args"}}},
                                                                                                                            "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                                                                                        "argument": {"variable": "elimHeadType"}}},
                                                                                                                    "argument": {"variable": "elimTerm"}}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "project",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "p",
                                                                                                    "domain": {"variable": "hydra.core.model.Projection"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"application": {"function": {"variable": "expand"}, "argument": {"literal": {"boolean": false}}}},
                                                                                                                    "argument": {"variable": "args"}}},
                                                                                                                "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                                                                            "argument": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                        "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "project", "term": {"variable": "p"}}}}}}}}},
                                                                                              {
                                                                                                "name": "unwrap",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "nm",
                                                                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"application": {"function": {"variable": "expand"}, "argument": {"literal": {"boolean": false}}}},
                                                                                                                    "argument": {"variable": "args"}}},
                                                                                                                "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                                                                            "argument": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                        "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "unwrap", "term": {"variable": "nm"}}}}}}}}},
                                                                                              {
                                                                                                "name": "lambda",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "lm",
                                                                                                    "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "tx1",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "hydra.core.scoping.extendGraphForLambda"}, "argument": {"variable": "tx"}}},
                                                                                                                "argument": {"variable": "lm"}}},
                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "let": {
                                                                                                            "bindings": [
                                                                                                              {
                                                                                                                "name": "body",
                                                                                                                "term": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {"variable": "rewriteWithArgs"},
                                                                                                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                        "argument": {"variable": "tx1"}}},
                                                                                                                    "argument": {
                                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "lm"}}}}},
                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                            "body": {
                                                                                                              "let": {
                                                                                                                "bindings": [
                                                                                                                  {
                                                                                                                    "name": "result",
                                                                                                                    "term": {
                                                                                                                      "inject": {
                                                                                                                        "typeName": "hydra.core.model.Term",
                                                                                                                        "field": {
                                                                                                                          "name": "lambda",
                                                                                                                          "term": {
                                                                                                                            "record": {
                                                                                                                              "typeName": "hydra.core.model.Lambda",
                                                                                                                              "fields": [
                                                                                                                                {
                                                                                                                                  "name": "parameter",
                                                                                                                                  "term": {
                                                                                                                                    "application": {
                                                                                                                                      "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
                                                                                                                                      "argument": {"variable": "lm"}}}},
                                                                                                                                {
                                                                                                                                  "name": "domain",
                                                                                                                                  "term": {
                                                                                                                                    "application": {
                                                                                                                                      "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "domain"}},
                                                                                                                                      "argument": {"variable": "lm"}}}},
                                                                                                                                {"name": "body", "term": {"variable": "body"}}]}}}}},
                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                "body": {
                                                                                                                  "let": {
                                                                                                                    "bindings": [
                                                                                                                      {
                                                                                                                        "name": "arty",
                                                                                                                        "term": {
                                                                                                                          "application": {
                                                                                                                            "function": {"application": {"function": {"variable": "termArityWithContext"}, "argument": {"variable": "tx"}}},
                                                                                                                            "argument": {"variable": "result"}}},
                                                                                                                        "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                                                                    "body": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"application": {"function": {"variable": "expand"}, "argument": {"literal": {"boolean": false}}}},
                                                                                                                                    "argument": {"variable": "args"}}},
                                                                                                                                "argument": {"variable": "arty"}}},
                                                                                                                            "argument": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                                        "argument": {"variable": "result"}}}}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "let",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "lt",
                                                                                                    "domain": {"variable": "hydra.core.model.Let"},
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "tx1",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {"variable": "hydra.core.scoping.extendGraphForLet"},
                                                                                                                        "argument": {
                                                                                                                          "lambda": {
                                                                                                                            "parameter": "_",
                                                                                                                            "domain": {"variable": "hydra.core.graph.Graph"},
                                                                                                                            "body": {
                                                                                                                              "lambda": {
                                                                                                                                "parameter": "_",
                                                                                                                                "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                                "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                                                                    "argument": {"variable": "tx"}}},
                                                                                                                "argument": {"variable": "lt"}}},
                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "let": {
                                                                                                            "bindings": [
                                                                                                              {
                                                                                                                "name": "mapBinding",
                                                                                                                "term": {
                                                                                                                  "lambda": {
                                                                                                                    "parameter": "b",
                                                                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                    "body": {
                                                                                                                      "record": {
                                                                                                                        "typeName": "hydra.core.model.Binding",
                                                                                                                        "fields": [
                                                                                                                          {
                                                                                                                            "name": "name",
                                                                                                                            "term": {
                                                                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}},
                                                                                                                          {
                                                                                                                            "name": "term",
                                                                                                                            "term": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {"variable": "rewriteWithArgs"},
                                                                                                                                        "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                    "argument": {"variable": "tx1"}}},
                                                                                                                                "argument": {
                                                                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}}},
                                                                                                                          {
                                                                                                                            "name": "typeScheme",
                                                                                                                            "term": {
                                                                                                                              "application": {
                                                                                                                                "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                                                                                                "argument": {"variable": "b"}}}}]}}}},
                                                                                                                "typeScheme": {
                                                                                                                  "variables": [],
                                                                                                                  "body": {"function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                  "constraints": []}}],
                                                                                                            "body": {
                                                                                                              "let": {
                                                                                                                "bindings": [
                                                                                                                  {
                                                                                                                    "name": "result",
                                                                                                                    "term": {
                                                                                                                      "inject": {
                                                                                                                        "typeName": "hydra.core.model.Term",
                                                                                                                        "field": {
                                                                                                                          "name": "let",
                                                                                                                          "term": {
                                                                                                                            "record": {
                                                                                                                              "typeName": "hydra.core.model.Let",
                                                                                                                              "fields": [
                                                                                                                                {
                                                                                                                                  "name": "bindings",
                                                                                                                                  "term": {
                                                                                                                                    "application": {
                                                                                                                                      "function": {
                                                                                                                                        "application": {
                                                                                                                                          "function": {
                                                                                                                                            "typeApplication": {
                                                                                                                                              "body": {
                                                                                                                                                "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                              "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                          "argument": {"variable": "mapBinding"}}},
                                                                                                                                      "argument": {
                                                                                                                                        "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "lt"}}}}}},
                                                                                                                                {
                                                                                                                                  "name": "body",
                                                                                                                                  "term": {
                                                                                                                                    "application": {
                                                                                                                                      "function": {
                                                                                                                                        "application": {
                                                                                                                                          "function": {
                                                                                                                                            "application": {
                                                                                                                                              "function": {"variable": "rewriteWithArgs"},
                                                                                                                                              "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                          "argument": {"variable": "tx1"}}},
                                                                                                                                      "argument": {
                                                                                                                                        "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "lt"}}}}}}]}}}}},
                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                "body": {"application": {"function": {"variable": "afterRecursion"}, "argument": {"variable": "result"}}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "list",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "els",
                                                                                                    "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "list",
                                                                                                              "term": {
                                                                                                                "application": {
                                                                                                                  "function": {
                                                                                                                    "application": {
                                                                                                                      "function": {
                                                                                                                        "typeApplication": {
                                                                                                                          "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                          "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                      "argument": {
                                                                                                                        "lambda": {
                                                                                                                          "parameter": "el",
                                                                                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                          "body": {
                                                                                                                            "application": {
                                                                                                                              "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                              "argument": {"variable": "el"}}}}}}},
                                                                                                                  "argument": {"variable": "els"}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "literal",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "v",
                                                                                                    "domain": {"variable": "hydra.core.model.Literal"},
                                                                                                    "body": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "literal", "term": {"variable": "v"}}}}}}},
                                                                                              {
                                                                                                "name": "map",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "mp",
                                                                                                    "domain": {"map": {"keys": {"variable": "hydra.core.model.Term"}, "values": {"variable": "hydra.core.model.Term"}}},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {"name": "map", "term": {"application": {"function": {"variable": "forMap"}, "argument": {"variable": "mp"}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "optional",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "mb",
                                                                                                    "domain": {"optional": {"variable": "hydra.core.model.Term"}},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "optional",
                                                                                                              "term": {
                                                                                                                "application": {
                                                                                                                  "function": {
                                                                                                                    "application": {
                                                                                                                      "function": {
                                                                                                                        "typeApplication": {
                                                                                                                          "body": {
                                                                                                                            "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                          "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                      "argument": {
                                                                                                                        "lambda": {
                                                                                                                          "parameter": "v",
                                                                                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                          "body": {
                                                                                                                            "application": {
                                                                                                                              "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                              "argument": {"variable": "v"}}}}}}},
                                                                                                                  "argument": {"variable": "mb"}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "pair",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "pr",
                                                                                                    "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"variable": "hydra.core.model.Term"}}},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "pair",
                                                                                                              "term": {
                                                                                                                "typeApplication": {
                                                                                                                  "body": {
                                                                                                                    "typeApplication": {
                                                                                                                      "body": {
                                                                                                                        "pair": {
                                                                                                                          "first": {
                                                                                                                            "application": {
                                                                                                                              "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                              "argument": {
                                                                                                                                "application": {
                                                                                                                                  "function": {
                                                                                                                                    "typeApplication": {
                                                                                                                                      "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                      "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                  "argument": {"variable": "pr"}}}}},
                                                                                                                          "second": {
                                                                                                                            "application": {
                                                                                                                              "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                              "argument": {
                                                                                                                                "application": {
                                                                                                                                  "function": {
                                                                                                                                    "typeApplication": {
                                                                                                                                      "body": {
                                                                                                                                        "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                      "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                  "argument": {"variable": "pr"}}}}}}},
                                                                                                                      "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                  "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "record",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "rc",
                                                                                                    "domain": {"variable": "hydra.core.model.Record"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "record",
                                                                                                              "term": {
                                                                                                                "record": {
                                                                                                                  "typeName": "hydra.core.model.Record",
                                                                                                                  "fields": [
                                                                                                                    {
                                                                                                                      "name": "typeName",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"project": {"typeName": "hydra.core.model.Record", "fieldName": "typeName"}},
                                                                                                                          "argument": {"variable": "rc"}}}},
                                                                                                                    {
                                                                                                                      "name": "fields",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {
                                                                                                                            "application": {
                                                                                                                              "function": {
                                                                                                                                "typeApplication": {
                                                                                                                                  "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Field"}}},
                                                                                                                                  "type": {"variable": "hydra.core.model.Field"}}},
                                                                                                                              "argument": {"variable": "forField"}}},
                                                                                                                          "argument": {
                                                                                                                            "application": {
                                                                                                                              "function": {"project": {"typeName": "hydra.core.model.Record", "fieldName": "fields"}},
                                                                                                                              "argument": {"variable": "rc"}}}}}}]}}}}}}}}}},
                                                                                              {
                                                                                                "name": "set",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "st",
                                                                                                    "domain": {"set": {"variable": "hydra.core.model.Term"}},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "set",
                                                                                                              "term": {
                                                                                                                "application": {
                                                                                                                  "function": {
                                                                                                                    "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                  "argument": {
                                                                                                                    "application": {
                                                                                                                      "function": {
                                                                                                                        "application": {
                                                                                                                          "function": {
                                                                                                                            "typeApplication": {
                                                                                                                              "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                              "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                          "argument": {
                                                                                                                            "lambda": {
                                                                                                                              "parameter": "el",
                                                                                                                              "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                              "body": {
                                                                                                                                "application": {
                                                                                                                                  "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                                  "argument": {"variable": "el"}}}}}}},
                                                                                                                      "argument": {
                                                                                                                        "application": {
                                                                                                                          "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.toList"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                          "argument": {"variable": "st"}}}}}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "typeApplication",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "tt",
                                                                                                    "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "gatherTypeApps",
                                                                                                            "term": {
                                                                                                              "lambda": {
                                                                                                                "parameter": "acc",
                                                                                                                "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                                                                                                "body": {
                                                                                                                  "lambda": {
                                                                                                                    "parameter": "trm",
                                                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                    "body": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "cases": {
                                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                                            "default": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {"pair": {"first": {"variable": "trm"}, "second": {"variable": "acc"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"list": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                            "cases": [
                                                                                                                              {
                                                                                                                                "name": "typeApplication",
                                                                                                                                "handler": {
                                                                                                                                  "lambda": {
                                                                                                                                    "parameter": "tt2",
                                                                                                                                    "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                                                                                                    "body": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {"variable": "gatherTypeApps"},
                                                                                                                                            "argument": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                                                    "argument": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
                                                                                                                                                        "argument": {"variable": "tt2"}}}}},
                                                                                                                                                "argument": {"variable": "acc"}}}}},
                                                                                                                                        "argument": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                                                                                            "argument": {"variable": "tt2"}}}}}}}}]}},
                                                                                                                        "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "trm"}}}}}}}}},
                                                                                                            "typeScheme": {
                                                                                                              "variables": [],
                                                                                                              "body": {
                                                                                                                "function": {
                                                                                                                  "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                                                                                                  "codomain": {
                                                                                                                    "function": {
                                                                                                                      "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                      "codomain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Type"}}}}}}}},
                                                                                                              "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "let": {
                                                                                                            "bindings": [
                                                                                                              {
                                                                                                                "name": "gathered",
                                                                                                                "term": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {"variable": "gatherTypeApps"},
                                                                                                                        "argument": {
                                                                                                                          "list": [
                                                                                                                            {
                                                                                                                              "application": {
                                                                                                                                "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
                                                                                                                                "argument": {"variable": "tt"}}}]}}},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                                                                        "argument": {"variable": "tt"}}}}},
                                                                                                                "typeScheme": {
                                                                                                                  "variables": [],
                                                                                                                  "body": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                  "constraints": []}}],
                                                                                                            "body": {
                                                                                                              "let": {
                                                                                                                "bindings": [
                                                                                                                  {
                                                                                                                    "name": "innermost",
                                                                                                                    "term": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "type": {"list": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                        "argument": {"variable": "gathered"}}},
                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                "body": {
                                                                                                                  "let": {
                                                                                                                    "bindings": [
                                                                                                                      {
                                                                                                                        "name": "tApps",
                                                                                                                        "term": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"list": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                            "argument": {"variable": "gathered"}}},
                                                                                                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                                                    "body": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "cases": {
                                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                                            "default": {
                                                                                                                              "application": {
                                                                                                                                "function": {"variable": "afterRecursion"},
                                                                                                                                "argument": {
                                                                                                                                  "inject": {
                                                                                                                                    "typeName": "hydra.core.model.Term",
                                                                                                                                    "field": {
                                                                                                                                      "name": "typeApplication",
                                                                                                                                      "term": {
                                                                                                                                        "record": {
                                                                                                                                          "typeName": "hydra.core.model.TypeApplicationTerm",
                                                                                                                                          "fields": [
                                                                                                                                            {
                                                                                                                                              "name": "body",
                                                                                                                                              "term": {
                                                                                                                                                "application": {
                                                                                                                                                  "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                                                  "argument": {
                                                                                                                                                    "application": {
                                                                                                                                                      "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                                                                                                      "argument": {"variable": "tt"}}}}}},
                                                                                                                                            {
                                                                                                                                              "name": "type",
                                                                                                                                              "term": {
                                                                                                                                                "application": {
                                                                                                                                                  "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
                                                                                                                                                  "argument": {"variable": "tt"}}}}]}}}}}}},
                                                                                                                            "cases": [
                                                                                                                              {
                                                                                                                                "name": "cases",
                                                                                                                                "handler": {
                                                                                                                                  "lambda": {
                                                                                                                                    "parameter": "cs",
                                                                                                                                    "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                                                    "body": {
                                                                                                                                      "let": {
                                                                                                                                        "bindings": [
                                                                                                                                          {
                                                                                                                                            "name": "newCs",
                                                                                                                                            "term": {
                                                                                                                                              "record": {
                                                                                                                                                "typeName": "hydra.core.model.CaseStatement",
                                                                                                                                                "fields": [
                                                                                                                                                  {
                                                                                                                                                    "name": "typeName",
                                                                                                                                                    "term": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "typeName"}},
                                                                                                                                                        "argument": {"variable": "cs"}}}},
                                                                                                                                                  {
                                                                                                                                                    "name": "default",
                                                                                                                                                    "term": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {
                                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                            "argument": {
                                                                                                                                                              "lambda": {
                                                                                                                                                                "parameter": "t1",
                                                                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                                "body": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                                                                    "argument": {"variable": "t1"}}}}}}},
                                                                                                                                                        "argument": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "default"}},
                                                                                                                                                            "argument": {"variable": "cs"}}}}}},
                                                                                                                                                  {
                                                                                                                                                    "name": "cases",
                                                                                                                                                    "term": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {
                                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                                                                                "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                                                                            "argument": {"variable": "forCaseBranch"}}},
                                                                                                                                                        "argument": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "cases"}},
                                                                                                                                                            "argument": {"variable": "cs"}}}}}}]}},
                                                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.CaseStatement"}, "constraints": []}}],
                                                                                                                                        "body": {
                                                                                                                                          "let": {
                                                                                                                                            "bindings": [
                                                                                                                                              {
                                                                                                                                                "name": "casesWithTypeApps",
                                                                                                                                                "term": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                                                            "argument": {
                                                                                                                                                              "lambda": {
                                                                                                                                                                "parameter": "trm",
                                                                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                                "body": {
                                                                                                                                                                  "lambda": {
                                                                                                                                                                    "parameter": "t",
                                                                                                                                                                    "domain": {"variable": "hydra.core.model.Type"},
                                                                                                                                                                    "body": {
                                                                                                                                                                      "inject": {
                                                                                                                                                                        "typeName": "hydra.core.model.Term",
                                                                                                                                                                        "field": {
                                                                                                                                                                          "name": "typeApplication",
                                                                                                                                                                          "term": {
                                                                                                                                                                            "record": {
                                                                                                                                                                              "typeName": "hydra.core.model.TypeApplicationTerm",
                                                                                                                                                                              "fields": [{"name": "body", "term": {"variable": "trm"}}, {"name": "type", "term": {"variable": "t"}}]}}}}}}}}}}},
                                                                                                                                                        "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "cases", "term": {"variable": "newCs"}}}}}},
                                                                                                                                                    "argument": {"variable": "tApps"}}},
                                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                                            "body": {
                                                                                                                                              "let": {
                                                                                                                                                "bindings": [
                                                                                                                                                  {
                                                                                                                                                    "name": "elimHeadTypeTyped",
                                                                                                                                                    "term": {
                                                                                                                                                      "optional": {
                                                                                                                                                        "inject": {
                                                                                                                                                          "typeName": "hydra.core.model.Type",
                                                                                                                                                          "field": {
                                                                                                                                                            "name": "function",
                                                                                                                                                            "term": {
                                                                                                                                                              "record": {
                                                                                                                                                                "typeName": "hydra.core.model.FunctionType",
                                                                                                                                                                "fields": [
                                                                                                                                                                  {
                                                                                                                                                                    "name": "domain",
                                                                                                                                                                    "term": {
                                                                                                                                                                      "application": {
                                                                                                                                                                        "function": {
                                                                                                                                                                          "application": {
                                                                                                                                                                            "function": {"variable": "hydra.core.resolution.nominalApplication"},
                                                                                                                                                                            "argument": {
                                                                                                                                                                              "application": {
                                                                                                                                                                                "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "typeName"}},
                                                                                                                                                                                "argument": {"variable": "cs"}}}}},
                                                                                                                                                                        "argument": {"variable": "tApps"}}}},
                                                                                                                                                                  {
                                                                                                                                                                    "name": "codomain",
                                                                                                                                                                    "term": {"inject": {"typeName": "hydra.core.model.Type", "field": {"name": "unit", "term": "unit"}}}}]}}}}}},
                                                                                                                                                    "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                                                                                "body": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {"application": {"function": {"variable": "expand"}, "argument": {"literal": {"boolean": true}}}},
                                                                                                                                                                "argument": {"variable": "args"}}},
                                                                                                                                                            "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                                                                                                                        "argument": {"variable": "elimHeadTypeTyped"}}},
                                                                                                                                                    "argument": {"variable": "casesWithTypeApps"}}}}}}}}}}}}]}},
                                                                                                                        "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "innermost"}}}}}}}}}}}}}}}},
                                                                                              {
                                                                                                "name": "typeLambda",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "tl",
                                                                                                    "domain": {"variable": "hydra.core.model.TypeLambda"},
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "tx1",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {"function": {"variable": "hydra.core.scoping.extendGraphForTypeLambda"}, "argument": {"variable": "tx"}}},
                                                                                                                "argument": {"variable": "tl"}}},
                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "let": {
                                                                                                            "bindings": [
                                                                                                              {
                                                                                                                "name": "result",
                                                                                                                "term": {
                                                                                                                  "inject": {
                                                                                                                    "typeName": "hydra.core.model.Term",
                                                                                                                    "field": {
                                                                                                                      "name": "typeLambda",
                                                                                                                      "term": {
                                                                                                                        "record": {
                                                                                                                          "typeName": "hydra.core.model.TypeLambda",
                                                                                                                          "fields": [
                                                                                                                            {
                                                                                                                              "name": "parameter",
                                                                                                                              "term": {
                                                                                                                                "application": {
                                                                                                                                  "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "parameter"}},
                                                                                                                                  "argument": {"variable": "tl"}}}},
                                                                                                                            {
                                                                                                                              "name": "body",
                                                                                                                              "term": {
                                                                                                                                "application": {
                                                                                                                                  "function": {
                                                                                                                                    "application": {
                                                                                                                                      "function": {
                                                                                                                                        "application": {
                                                                                                                                          "function": {"variable": "rewriteWithArgs"},
                                                                                                                                          "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                      "argument": {"variable": "tx1"}}},
                                                                                                                                  "argument": {
                                                                                                                                    "application": {
                                                                                                                                      "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "body"}},
                                                                                                                                      "argument": {"variable": "tl"}}}}}}]}}}}},
                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                            "body": {"application": {"function": {"variable": "afterRecursion"}, "argument": {"variable": "result"}}}}}}}}}},
                                                                                              {
                                                                                                "name": "inject",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "inj",
                                                                                                    "domain": {"variable": "hydra.core.model.Injection"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "inject",
                                                                                                              "term": {
                                                                                                                "record": {
                                                                                                                  "typeName": "hydra.core.model.Injection",
                                                                                                                  "fields": [
                                                                                                                    {
                                                                                                                      "name": "typeName",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"project": {"typeName": "hydra.core.model.Injection", "fieldName": "typeName"}},
                                                                                                                          "argument": {"variable": "inj"}}}},
                                                                                                                    {
                                                                                                                      "name": "field",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"variable": "forField"},
                                                                                                                          "argument": {
                                                                                                                            "application": {
                                                                                                                              "function": {"project": {"typeName": "hydra.core.model.Injection", "fieldName": "field"}},
                                                                                                                              "argument": {"variable": "inj"}}}}}}]}}}}}}}}}},
                                                                                              {
                                                                                                "name": "unit",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "_",
                                                                                                    "domain": "unit",
                                                                                                    "body": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "unit", "term": "unit"}}}}}},
                                                                                              {
                                                                                                "name": "variable",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "vn",
                                                                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "arty",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "termArityWithContext"}, "argument": {"variable": "tx"}}},
                                                                                                                "argument": {"variable": "term"}}},
                                                                                                            "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "let": {
                                                                                                            "bindings": [
                                                                                                              {
                                                                                                                "name": "varType",
                                                                                                                "term": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {
                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                                            "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                        "argument": {"variable": "hydra.core.scoping.typeSchemeToFType"}}},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                                            "argument": {"variable": "vn"}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
                                                                                                                            "argument": {"variable": "tx"}}}}}}},
                                                                                                                "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                                            "body": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {"application": {"function": {"variable": "expand"}, "argument": {"literal": {"boolean": false}}}},
                                                                                                                            "argument": {"variable": "args"}}},
                                                                                                                        "argument": {"variable": "arty"}}},
                                                                                                                    "argument": {"variable": "varType"}}},
                                                                                                                "argument": {"variable": "term"}}}}}}}}}},
                                                                                              {
                                                                                                "name": "wrap",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "wt",
                                                                                                    "domain": {"variable": "hydra.core.model.WrappedTerm"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "afterRecursion"},
                                                                                                        "argument": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "wrap",
                                                                                                              "term": {
                                                                                                                "record": {
                                                                                                                  "typeName": "hydra.core.model.WrappedTerm",
                                                                                                                  "fields": [
                                                                                                                    {
                                                                                                                      "name": "typeName",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"project": {"typeName": "hydra.core.model.WrappedTerm", "fieldName": "typeName"}},
                                                                                                                          "argument": {"variable": "wt"}}}},
                                                                                                                    {
                                                                                                                      "name": "body",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                                          "argument": {
                                                                                                                            "application": {
                                                                                                                              "function": {"project": {"typeName": "hydra.core.model.WrappedTerm", "fieldName": "body"}},
                                                                                                                              "argument": {"variable": "wt"}}}}}}]}}}}}}}}}}]}},
                                                                                        "argument": {"variable": "term"}}}}}}}}}}}}}}}}}}}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {
                                                    "function": {
                                                      "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                      "codomain": {
                                                        "function": {
                                                          "domain": {"variable": "hydra.core.graph.Graph"},
                                                          "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "application": {
                                                "function": {"variable": "hydra.core.reduction.contractTerm"},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"variable": "rewriteWithArgs"},
                                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                                        "argument": {"variable": "tx0"}}},
                                                    "argument": {"variable": "term0"}}}}}}}}}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Recursively transform terms to eliminate partial application, e.g. 'add 42' becomes '\\x.add 42 x'. Uses the Graph to look up types for arity calculation. Bare primitives and variables are NOT expanded; eliminations and partial applications are. This version properly tracks the Graph through nested scopes."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.etaExpandTypedTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.typing.InferenceContext"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg2", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "cx",
                "domain": {"variable": "hydra.core.typing.InferenceContext"},
                "body": {
                  "lambda": {
                    "parameter": "tx0",
                    "domain": {"variable": "hydra.core.graph.Graph"},
                    "body": {
                      "lambda": {
                        "parameter": "term0",
                        "domain": {"variable": "hydra.core.model.Term"},
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "rewrite",
                                "term": {
                                  "lambda": {
                                    "parameter": "topLevel",
                                    "domain": {"literal": "boolean"},
                                    "body": {
                                      "lambda": {
                                        "parameter": "forced",
                                        "domain": {"literal": "boolean"},
                                        "body": {
                                          "lambda": {
                                            "parameter": "typeArgs",
                                            "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                            "body": {
                                              "lambda": {
                                                "parameter": "recurse",
                                                "domain": {
                                                  "function": {
                                                    "domain": {"variable": "hydra.core.graph.Graph"},
                                                    "codomain": {
                                                      "function": {
                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                        "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "tx",
                                                    "domain": {"variable": "hydra.core.graph.Graph"},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "term",
                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "rewriteSpine",
                                                                "term": {
                                                                  "lambda": {
                                                                    "parameter": "term",
                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "cases": {
                                                                            "typeName": "hydra.core.model.Term",
                                                                            "default": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"literal": {"boolean": false}}}},
                                                                                                "argument": {"literal": {"boolean": false}}}},
                                                                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                        "argument": {"variable": "recurse"}}},
                                                                                    "argument": {"variable": "tx"}}},
                                                                                "argument": {"variable": "term"}}},
                                                                            "cases": [
                                                                              {
                                                                                "name": "annotated",
                                                                                "handler": {
                                                                                  "lambda": {
                                                                                    "parameter": "at",
                                                                                    "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {"variable": "rewriteSpine"},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                                                    "argument": {"variable": "at"}}}}}}},
                                                                                        "argument": {
                                                                                          "lambda": {
                                                                                            "parameter": "body",
                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "ann",
                                                                                                    "term": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "annotation"}},
                                                                                                        "argument": {"variable": "at"}}},
                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "either": {
                                                                                                            "right": {
                                                                                                              "inject": {
                                                                                                                "typeName": "hydra.core.model.Term",
                                                                                                                "field": {
                                                                                                                  "name": "annotated",
                                                                                                                  "term": {
                                                                                                                    "record": {
                                                                                                                      "typeName": "hydra.core.model.AnnotatedTerm",
                                                                                                                      "fields": [{"name": "body", "term": {"variable": "body"}}, {"name": "annotation", "term": {"variable": "ann"}}]}}}}}}},
                                                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}}},
                                                                              {
                                                                                "name": "application",
                                                                                "handler": {
                                                                                  "lambda": {
                                                                                    "parameter": "a",
                                                                                    "domain": {"variable": "hydra.core.model.Application"},
                                                                                    "body": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "l",
                                                                                            "term": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"list": {"variable": "hydra.core.model.Type"}}}},
                                                                                                        "argument": {"literal": {"boolean": false}}}},
                                                                                                    "argument": {
                                                                                                      "list": [
                                                                                                        {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Type",
                                                                                                            "field": {
                                                                                                              "name": "literal",
                                                                                                              "term": {"inject": {"typeName": "hydra.core.model.LiteralType", "field": {"name": "string", "term": "unit"}}}}}}]}}},
                                                                                                "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                            "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {"variable": "rewriteSpine"},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                                                                        "argument": {"variable": "a"}}}}}}},
                                                                                            "argument": {
                                                                                              "lambda": {
                                                                                                "parameter": "lhs",
                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"literal": {"boolean": true}}}},
                                                                                                                            "argument": {"literal": {"boolean": false}}}},
                                                                                                                        "argument": {"variable": "l"}}},
                                                                                                                    "argument": {"variable": "recurse"}}},
                                                                                                                "argument": {"variable": "tx"}}},
                                                                                                            "argument": {
                                                                                                              "application": {
                                                                                                                "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "argument"}},
                                                                                                                "argument": {"variable": "a"}}}}}}},
                                                                                                    "argument": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "rhs",
                                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                                        "body": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "either": {
                                                                                                                    "right": {
                                                                                                                      "inject": {
                                                                                                                        "typeName": "hydra.core.model.Term",
                                                                                                                        "field": {
                                                                                                                          "name": "application",
                                                                                                                          "term": {
                                                                                                                            "record": {
                                                                                                                              "typeName": "hydra.core.model.Application",
                                                                                                                              "fields": [{"name": "function", "term": {"variable": "lhs"}}, {"name": "argument", "term": {"variable": "rhs"}}]}}}}}}},
                                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}}}}}}},
                                                                              {
                                                                                "name": "typeApplication",
                                                                                "handler": {
                                                                                  "lambda": {
                                                                                    "parameter": "tat",
                                                                                    "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {"variable": "rewriteSpine"},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                                                    "argument": {"variable": "tat"}}}}}}},
                                                                                        "argument": {
                                                                                          "lambda": {
                                                                                            "parameter": "body",
                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "typ",
                                                                                                    "term": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
                                                                                                        "argument": {"variable": "tat"}}},
                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "either": {
                                                                                                            "right": {
                                                                                                              "inject": {
                                                                                                                "typeName": "hydra.core.model.Term",
                                                                                                                "field": {
                                                                                                                  "name": "typeApplication",
                                                                                                                  "term": {
                                                                                                                    "record": {
                                                                                                                      "typeName": "hydra.core.model.TypeApplicationTerm",
                                                                                                                      "fields": [{"name": "body", "term": {"variable": "body"}}, {"name": "type", "term": {"variable": "typ"}}]}}}}}}},
                                                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}}}]}},
                                                                        "argument": {"variable": "term"}}}}},
                                                                "typeScheme": {
                                                                  "variables": [],
                                                                  "body": {
                                                                    "function": {
                                                                      "domain": {"variable": "hydra.core.model.Term"},
                                                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                  "constraints": []}}],
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "arityOf",
                                                                    "term": {
                                                                      "lambda": {
                                                                        "parameter": "tx",
                                                                        "domain": {"variable": "hydra.core.graph.Graph"},
                                                                        "body": {
                                                                          "lambda": {
                                                                            "parameter": "term",
                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "dflt",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"variable": "hydra.core.lib.eithers.map"},
                                                                                                        "type": {"pair": {"first": {"variable": "hydra.core.model.Type"}, "second": {"variable": "hydra.core.typing.InferenceContext"}}}}},
                                                                                                    "type": {"literal": {"integer": "int32"}}}},
                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                            "argument": {
                                                                                              "lambda": {
                                                                                                "parameter": "_tc",
                                                                                                "domain": {"pair": {"first": {"variable": "hydra.core.model.Type"}, "second": {"variable": "hydra.core.typing.InferenceContext"}}},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {"variable": "hydra.core.arity.typeArity"},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                            "type": {"variable": "hydra.core.typing.InferenceContext"}}},
                                                                                                        "argument": {"variable": "_tc"}}}}}}}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {"application": {"function": {"variable": "hydra.core.checking.typeOf"}, "argument": {"variable": "cx"}}},
                                                                                                    "argument": {"variable": "tx"}}},
                                                                                                "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                            "argument": {"variable": "term"}}}}},
                                                                                    "typeScheme": {
                                                                                      "variables": [],
                                                                                      "body": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"literal": {"integer": "int32"}}}},
                                                                                      "constraints": []}}],
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "cases": {
                                                                                        "typeName": "hydra.core.model.Term",
                                                                                        "default": {"variable": "dflt"},
                                                                                        "cases": [
                                                                                          {
                                                                                            "name": "annotated",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "at",
                                                                                                "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {"application": {"function": {"variable": "arityOf"}, "argument": {"variable": "tx"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                                                        "argument": {"variable": "at"}}}}}}}},
                                                                                          {
                                                                                            "name": "cases",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "_",
                                                                                                "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"either": {"right": {"literal": {"integer": {"int32": 1}}}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                    "type": {"literal": {"integer": "int32"}}}}}}},
                                                                                          {
                                                                                            "name": "project",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "_",
                                                                                                "domain": {"variable": "hydra.core.model.Projection"},
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"either": {"right": {"literal": {"integer": {"int32": 1}}}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                    "type": {"literal": {"integer": "int32"}}}}}}},
                                                                                          {
                                                                                            "name": "unwrap",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "_",
                                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"either": {"right": {"literal": {"integer": {"int32": 1}}}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                    "type": {"literal": {"integer": "int32"}}}}}}},
                                                                                          {
                                                                                            "name": "lambda",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "l",
                                                                                                "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                                "body": {
                                                                                                  "let": {
                                                                                                    "bindings": [
                                                                                                      {
                                                                                                        "name": "txl",
                                                                                                        "term": {
                                                                                                          "application": {
                                                                                                            "function": {"application": {"function": {"variable": "hydra.core.scoping.extendGraphForLambda"}, "argument": {"variable": "tx"}}},
                                                                                                            "argument": {"variable": "l"}}},
                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "arityOf"}, "argument": {"variable": "txl"}}},
                                                                                                        "argument": {
                                                                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}}}}},
                                                                                          {
                                                                                            "name": "let",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "l",
                                                                                                "domain": {"variable": "hydra.core.model.Let"},
                                                                                                "body": {
                                                                                                  "let": {
                                                                                                    "bindings": [
                                                                                                      {
                                                                                                        "name": "txl",
                                                                                                        "term": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "hydra.core.scoping.extendGraphForLet"},
                                                                                                                    "argument": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "_",
                                                                                                                        "domain": {"variable": "hydra.core.graph.Graph"},
                                                                                                                        "body": {
                                                                                                                          "lambda": {
                                                                                                                            "parameter": "_",
                                                                                                                            "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                            "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                                                                "argument": {"variable": "tx"}}},
                                                                                                            "argument": {"variable": "l"}}},
                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "arityOf"}, "argument": {"variable": "txl"}}},
                                                                                                        "argument": {
                                                                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}}}}},
                                                                                          {
                                                                                            "name": "typeApplication",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "tat",
                                                                                                "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {"application": {"function": {"variable": "arityOf"}, "argument": {"variable": "tx"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                                                        "argument": {"variable": "tat"}}}}}}}},
                                                                                          {
                                                                                            "name": "typeLambda",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "tl",
                                                                                                "domain": {"variable": "hydra.core.model.TypeLambda"},
                                                                                                "body": {
                                                                                                  "let": {
                                                                                                    "bindings": [
                                                                                                      {
                                                                                                        "name": "txt",
                                                                                                        "term": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {"function": {"variable": "hydra.core.scoping.extendGraphForTypeLambda"}, "argument": {"variable": "tx"}}},
                                                                                                            "argument": {"variable": "tl"}}},
                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "arityOf"}, "argument": {"variable": "txt"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "body"}},
                                                                                                            "argument": {"variable": "tl"}}}}}}}}}},
                                                                                          {
                                                                                            "name": "variable",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "name",
                                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"literal": {"integer": "int32"}}}}}},
                                                                                                            "argument": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {
                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                                        "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                    "argument": {"variable": "hydra.core.scoping.typeSchemeToFType"}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                            "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                                        "argument": {"variable": "name"}}},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
                                                                                                                        "argument": {"variable": "tx"}}}}}}}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {"variable": "hydra.core.lib.eithers.map"},
                                                                                                                            "type": {"pair": {"first": {"variable": "hydra.core.model.Type"}, "second": {"variable": "hydra.core.typing.InferenceContext"}}}}},
                                                                                                                        "type": {"literal": {"integer": "int32"}}}},
                                                                                                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                "argument": {
                                                                                                                  "lambda": {
                                                                                                                    "parameter": "_tc",
                                                                                                                    "domain": {"pair": {"first": {"variable": "hydra.core.model.Type"}, "second": {"variable": "hydra.core.typing.InferenceContext"}}},
                                                                                                                    "body": {
                                                                                                                      "application": {
                                                                                                                        "function": {"variable": "hydra.core.arity.typeArity"},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                                "type": {"variable": "hydra.core.typing.InferenceContext"}}},
                                                                                                                            "argument": {"variable": "_tc"}}}}}}}}},
                                                                                                            "argument": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {"application": {"function": {"variable": "hydra.core.checking.typeOf"}, "argument": {"variable": "cx"}}},
                                                                                                                        "argument": {"variable": "tx"}}},
                                                                                                                    "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                                "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "variable", "term": {"variable": "name"}}}}}}}}}},
                                                                                                    "argument": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "t",
                                                                                                        "domain": {"variable": "hydra.core.model.Type"},
                                                                                                        "body": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "either": {"right": {"application": {"function": {"variable": "hydra.core.arity.typeArity"}, "argument": {"variable": "t"}}}}},
                                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                            "type": {"literal": {"integer": "int32"}}}}}}}}}}}]}},
                                                                                    "argument": {"variable": "term"}}}}}}}}},
                                                                    "typeScheme": {
                                                                      "variables": [],
                                                                      "body": {
                                                                        "function": {
                                                                          "domain": {"variable": "hydra.core.graph.Graph"},
                                                                          "codomain": {
                                                                            "function": {
                                                                              "domain": {"variable": "hydra.core.model.Term"},
                                                                              "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"literal": {"integer": "int32"}}}}}}}},
                                                                      "constraints": []}}],
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "extraVariables",
                                                                        "term": {
                                                                          "lambda": {
                                                                            "parameter": "n",
                                                                            "domain": {"literal": {"integer": "int32"}},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {
                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "argument": {
                                                                                      "lambda": {
                                                                                        "parameter": "i",
                                                                                        "domain": {"literal": {"integer": "int32"}},
                                                                                        "body": {
                                                                                          "wrap": {
                                                                                            "typeName": "hydra.core.model.Name",
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "v"}}}},
                                                                                                "argument": {"application": {"function": {"variable": "hydra.core.lib.literals.printInt32"}, "argument": {"variable": "i"}}}}}}}}}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {"function": {"variable": "hydra.core.lib.math.range"}, "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.add"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                            "argument": {"variable": "n"}}},
                                                                                        "argument": {"literal": {"integer": {"int32": 1}}}}}}}}}}},
                                                                        "typeScheme": {
                                                                          "variables": [],
                                                                          "body": {"function": {"domain": {"literal": {"integer": "int32"}}, "codomain": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                          "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "pad",
                                                                            "term": {
                                                                              "lambda": {
                                                                                "parameter": "vars",
                                                                                "domain": {"list": {"variable": "hydra.core.model.Name"}},
                                                                                "body": {
                                                                                  "lambda": {
                                                                                    "parameter": "body",
                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"variable": "hydra.core.lib.optionals.match"},
                                                                                                        "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.uncons"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "argument": {"variable": "vars"}}}}},
                                                                                            "argument": {"variable": "body"}}},
                                                                                        "argument": {
                                                                                          "lambda": {
                                                                                            "parameter": "uc",
                                                                                            "domain": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "v0",
                                                                                                    "term": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                                        "argument": {"variable": "uc"}}},
                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                                "body": {
                                                                                                  "let": {
                                                                                                    "bindings": [
                                                                                                      {
                                                                                                        "name": "vrest",
                                                                                                        "term": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                                            "argument": {"variable": "uc"}}},
                                                                                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "inject": {
                                                                                                        "typeName": "hydra.core.model.Term",
                                                                                                        "field": {
                                                                                                          "name": "lambda",
                                                                                                          "term": {
                                                                                                            "record": {
                                                                                                              "typeName": "hydra.core.model.Lambda",
                                                                                                              "fields": [
                                                                                                                {"name": "parameter", "term": {"variable": "v0"}},
                                                                                                                {
                                                                                                                  "name": "domain",
                                                                                                                  "term": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Type"}}}},
                                                                                                                {
                                                                                                                  "name": "body",
                                                                                                                  "term": {
                                                                                                                    "application": {
                                                                                                                      "function": {"application": {"function": {"variable": "pad"}, "argument": {"variable": "vrest"}}},
                                                                                                                      "argument": {
                                                                                                                        "inject": {
                                                                                                                          "typeName": "hydra.core.model.Term",
                                                                                                                          "field": {
                                                                                                                            "name": "application",
                                                                                                                            "term": {
                                                                                                                              "record": {
                                                                                                                                "typeName": "hydra.core.model.Application",
                                                                                                                                "fields": [
                                                                                                                                  {"name": "function", "term": {"variable": "body"}},
                                                                                                                                  {
                                                                                                                                    "name": "argument",
                                                                                                                                    "term": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "variable", "term": {"variable": "v0"}}}}}]}}}}}}}}]}}}}}}}}}}}}}}}}},
                                                                            "typeScheme": {
                                                                              "variables": [],
                                                                              "body": {
                                                                                "function": {
                                                                                  "domain": {"list": {"variable": "hydra.core.model.Name"}},
                                                                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                                                              "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "padn",
                                                                                "term": {
                                                                                  "lambda": {
                                                                                    "parameter": "n",
                                                                                    "domain": {"literal": {"integer": "int32"}},
                                                                                    "body": {
                                                                                      "lambda": {
                                                                                        "parameter": "body",
                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {"variable": "pad"},
                                                                                                "argument": {"application": {"function": {"variable": "extraVariables"}, "argument": {"variable": "n"}}}}},
                                                                                            "argument": {"variable": "body"}}}}}}},
                                                                                "typeScheme": {
                                                                                  "variables": [],
                                                                                  "body": {
                                                                                    "function": {
                                                                                      "domain": {"literal": {"integer": "int32"}},
                                                                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                                                                  "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "unwind",
                                                                                    "term": {
                                                                                      "lambda": {
                                                                                        "parameter": "term",
                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                        "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                    "argument": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "e",
                                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                                        "body": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "t",
                                                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                                                            "body": {
                                                                                                              "inject": {
                                                                                                                "typeName": "hydra.core.model.Term",
                                                                                                                "field": {
                                                                                                                  "name": "typeApplication",
                                                                                                                  "term": {
                                                                                                                    "record": {
                                                                                                                      "typeName": "hydra.core.model.TypeApplicationTerm",
                                                                                                                      "fields": [{"name": "body", "term": {"variable": "e"}}, {"name": "type", "term": {"variable": "t"}}]}}}}}}}}}}},
                                                                                                "argument": {"variable": "term"}}},
                                                                                            "argument": {"variable": "typeArgs"}}}}},
                                                                                    "typeScheme": {
                                                                                      "variables": [],
                                                                                      "body": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                                                                      "constraints": []}}],
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "forceExpansion",
                                                                                        "term": {
                                                                                          "lambda": {
                                                                                            "parameter": "t",
                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                            "type": {"pair": {"first": {"variable": "hydra.core.model.Type"}, "second": {"variable": "hydra.core.typing.InferenceContext"}}}}},
                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "hydra.core.checking.typeOf"}, "argument": {"variable": "cx"}}},
                                                                                                                "argument": {"variable": "tx"}}},
                                                                                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                        "argument": {"variable": "t"}}}}},
                                                                                                "argument": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "typCx",
                                                                                                    "domain": {"pair": {"first": {"variable": "hydra.core.model.Type"}, "second": {"variable": "hydra.core.typing.InferenceContext"}}},
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "arity",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {"variable": "hydra.core.arity.typeArity"},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                        "type": {"variable": "hydra.core.typing.InferenceContext"}}},
                                                                                                                    "argument": {"variable": "typCx"}}}}},
                                                                                                            "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "either": {
                                                                                                                    "right": {
                                                                                                                      "application": {
                                                                                                                        "function": {"application": {"function": {"variable": "padn"}, "argument": {"variable": "arity"}}},
                                                                                                                        "argument": {"application": {"function": {"variable": "unwind"}, "argument": {"variable": "t"}}}}}}},
                                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}},
                                                                                        "typeScheme": {
                                                                                          "variables": [],
                                                                                          "body": {
                                                                                            "function": {
                                                                                              "domain": {"variable": "hydra.core.model.Term"},
                                                                                              "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                          "constraints": []}}],
                                                                                    "body": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "recurseOrForce",
                                                                                            "term": {
                                                                                              "lambda": {
                                                                                                "parameter": "term",
                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                            "argument": {"variable": "forced"}}},
                                                                                                        "argument": {"application": {"function": {"variable": "forceExpansion"}, "argument": {"variable": "term"}}}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "tx"}}},
                                                                                                        "argument": {"application": {"function": {"variable": "unwind"}, "argument": {"variable": "term"}}}}}}}}},
                                                                                            "typeScheme": {
                                                                                              "variables": [],
                                                                                              "body": {
                                                                                                "function": {
                                                                                                  "domain": {"variable": "hydra.core.model.Term"},
                                                                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                              "constraints": []}}],
                                                                                        "body": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "forCase",
                                                                                                "term": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "f",
                                                                                                    "domain": {"variable": "hydra.core.model.CaseAlternative"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {
                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                            "argument": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"literal": {"boolean": false}}}},
                                                                                                                                "argument": {"literal": {"boolean": true}}}},
                                                                                                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                                        "argument": {"variable": "recurse"}}},
                                                                                                                    "argument": {"variable": "tx"}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.CaseAlternative", "fieldName": "handler"}},
                                                                                                                    "argument": {"variable": "f"}}}}}}},
                                                                                                        "argument": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "r",
                                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                                            "body": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {
                                                                                                                      "either": {
                                                                                                                        "right": {
                                                                                                                          "record": {
                                                                                                                            "typeName": "hydra.core.model.CaseAlternative",
                                                                                                                            "fields": [
                                                                                                                              {
                                                                                                                                "name": "name",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.CaseAlternative", "fieldName": "name"}},
                                                                                                                                    "argument": {"variable": "f"}}}},
                                                                                                                              {"name": "handler", "term": {"variable": "r"}}]}}}},
                                                                                                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                "type": {"variable": "hydra.core.model.CaseAlternative"}}}}}}}}},
                                                                                                "typeScheme": {
                                                                                                  "variables": [],
                                                                                                  "body": {
                                                                                                    "function": {
                                                                                                      "domain": {"variable": "hydra.core.model.CaseAlternative"},
                                                                                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.CaseAlternative"}}}}},
                                                                                                  "constraints": []}}],
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "forCaseStatement",
                                                                                                    "term": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "cs",
                                                                                                        "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                        "body": {
                                                                                                          "let": {
                                                                                                            "bindings": [
                                                                                                              {
                                                                                                                "name": "tname",
                                                                                                                "term": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "typeName"}},
                                                                                                                    "argument": {"variable": "cs"}}},
                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                                            "body": {
                                                                                                              "let": {
                                                                                                                "bindings": [
                                                                                                                  {
                                                                                                                    "name": "dflt",
                                                                                                                    "term": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "default"}},
                                                                                                                        "argument": {"variable": "cs"}}},
                                                                                                                    "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                                                                                "body": {
                                                                                                                  "let": {
                                                                                                                    "bindings": [
                                                                                                                      {
                                                                                                                        "name": "csCases",
                                                                                                                        "term": {
                                                                                                                          "application": {
                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "cases"}},
                                                                                                                            "argument": {"variable": "cs"}}},
                                                                                                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.CaseAlternative"}}, "constraints": []}}],
                                                                                                                    "body": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "type": {"optional": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.mapOptional"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"literal": {"boolean": false}}}},
                                                                                                                                                    "argument": {"literal": {"boolean": false}}}},
                                                                                                                                                "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                                                            "argument": {"variable": "recurse"}}},
                                                                                                                                        "argument": {"variable": "tx"}}}}},
                                                                                                                                "argument": {"variable": "dflt"}}}}},
                                                                                                                        "argument": {
                                                                                                                          "lambda": {
                                                                                                                            "parameter": "rdflt",
                                                                                                                            "domain": {"optional": {"variable": "hydra.core.model.Term"}},
                                                                                                                            "body": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                            "type": {"list": {"variable": "hydra.core.model.CaseAlternative"}}}},
                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "typeApplication": {
                                                                                                                                                "body": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.mapList"}, "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                                                                    "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                            "argument": {"variable": "forCase"}}},
                                                                                                                                        "argument": {"variable": "csCases"}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "lambda": {
                                                                                                                                    "parameter": "rcases",
                                                                                                                                    "domain": {"list": {"variable": "hydra.core.model.CaseAlternative"}},
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "either": {
                                                                                                                                                "right": {
                                                                                                                                                  "inject": {
                                                                                                                                                    "typeName": "hydra.core.model.Term",
                                                                                                                                                    "field": {
                                                                                                                                                      "name": "cases",
                                                                                                                                                      "term": {
                                                                                                                                                        "record": {
                                                                                                                                                          "typeName": "hydra.core.model.CaseStatement",
                                                                                                                                                          "fields": [
                                                                                                                                                            {"name": "typeName", "term": {"variable": "tname"}},
                                                                                                                                                            {"name": "default", "term": {"variable": "rdflt"}},
                                                                                                                                                            {"name": "cases", "term": {"variable": "rcases"}}]}}}}}}},
                                                                                                                                            "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}}}}}}}}}},
                                                                                                    "typeScheme": {
                                                                                                      "variables": [],
                                                                                                      "body": {
                                                                                                        "function": {
                                                                                                          "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                          "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                      "constraints": []}}],
                                                                                                "body": {
                                                                                                  "let": {
                                                                                                    "bindings": [
                                                                                                      {
                                                                                                        "name": "forCases",
                                                                                                        "term": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "cs",
                                                                                                            "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                            "body": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {
                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.eithers.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                            "argument": {"variable": "unwind"}}},
                                                                                                                        "argument": {"application": {"function": {"variable": "forCaseStatement"}, "argument": {"variable": "cs"}}}}}}},
                                                                                                                "argument": {
                                                                                                                  "lambda": {
                                                                                                                    "parameter": "base",
                                                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                    "body": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {
                                                                                                                              "either": {
                                                                                                                                "right": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                            "argument": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {"application": {"function": {"variable": "hydra.core.lib.logic.or"}, "argument": {"variable": "topLevel"}}},
                                                                                                                                                "argument": {"variable": "forced"}}}}},
                                                                                                                                        "argument": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {"application": {"function": {"variable": "padn"}, "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                                                                                                            "argument": {"variable": "base"}}}}},
                                                                                                                                    "argument": {"variable": "base"}}}}},
                                                                                                                            "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                                                        "typeScheme": {
                                                                                                          "variables": [],
                                                                                                          "body": {
                                                                                                            "function": {
                                                                                                              "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                              "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                          "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "forNullaryElim",
                                                                                                            "term": {
                                                                                                              "lambda": {
                                                                                                                "parameter": "elimTerm",
                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                "body": {
                                                                                                                  "let": {
                                                                                                                    "bindings": [
                                                                                                                      {
                                                                                                                        "name": "base",
                                                                                                                        "term": {"application": {"function": {"variable": "unwind"}, "argument": {"variable": "elimTerm"}}},
                                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                    "body": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "argument": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"application": {"function": {"variable": "hydra.core.lib.logic.or"}, "argument": {"variable": "topLevel"}}},
                                                                                                                                    "argument": {"variable": "forced"}}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "padn"}, "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                                                                                                "argument": {"variable": "base"}}}}},
                                                                                                                        "argument": {"variable": "base"}}}}}}},
                                                                                                            "typeScheme": {
                                                                                                              "variables": [],
                                                                                                              "body": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                                                                                              "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "cases": {
                                                                                                                "typeName": "hydra.core.model.Term",
                                                                                                                "default": {"application": {"function": {"variable": "recurseOrForce"}, "argument": {"variable": "term"}}},
                                                                                                                "cases": [
                                                                                                                  {
                                                                                                                    "name": "application",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "a",
                                                                                                                        "domain": {"variable": "hydra.core.model.Application"},
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "lhs",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                                                                                                    "argument": {"variable": "a"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "let": {
                                                                                                                                "bindings": [
                                                                                                                                  {
                                                                                                                                    "name": "rhs",
                                                                                                                                    "term": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "argument"}},
                                                                                                                                        "argument": {"variable": "a"}}},
                                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                                "body": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {
                                                                                                                                                "body": {
                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"literal": {"boolean": true}}}},
                                                                                                                                                            "argument": {"literal": {"boolean": false}}}},
                                                                                                                                                        "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                                                                                                    "argument": {"variable": "recurse"}}},
                                                                                                                                                "argument": {"variable": "tx"}}},
                                                                                                                                            "argument": {"variable": "rhs"}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "lambda": {
                                                                                                                                        "parameter": "rhs2",
                                                                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                        "body": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {
                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                        "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                "argument": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {"application": {"function": {"variable": "arityOf"}, "argument": {"variable": "tx"}}},
                                                                                                                                                    "argument": {"variable": "lhs"}}}}},
                                                                                                                                            "argument": {
                                                                                                                                              "lambda": {
                                                                                                                                                "parameter": "lhsarity",
                                                                                                                                                "domain": {"literal": {"integer": "int32"}},
                                                                                                                                                "body": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "typeApplication": {
                                                                                                                                                            "body": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {
                                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                        "argument": {"application": {"function": {"variable": "rewriteSpine"}, "argument": {"variable": "lhs"}}}}},
                                                                                                                                                    "argument": {
                                                                                                                                                      "lambda": {
                                                                                                                                                        "parameter": "lhs2",
                                                                                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                        "body": {
                                                                                                                                                          "let": {
                                                                                                                                                            "bindings": [
                                                                                                                                                              {
                                                                                                                                                                "name": "a2",
                                                                                                                                                                "term": {
                                                                                                                                                                  "inject": {
                                                                                                                                                                    "typeName": "hydra.core.model.Term",
                                                                                                                                                                    "field": {
                                                                                                                                                                      "name": "application",
                                                                                                                                                                      "term": {
                                                                                                                                                                        "record": {
                                                                                                                                                                          "typeName": "hydra.core.model.Application",
                                                                                                                                                                          "fields": [{"name": "function", "term": {"variable": "lhs2"}}, {"name": "argument", "term": {"variable": "rhs2"}}]}}}}},
                                                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                                                            "body": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {
                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                    "body": {
                                                                                                                                                                      "either": {
                                                                                                                                                                        "right": {
                                                                                                                                                                          "application": {
                                                                                                                                                                            "function": {
                                                                                                                                                                              "application": {
                                                                                                                                                                                "function": {
                                                                                                                                                                                  "application": {
                                                                                                                                                                                    "function": {
                                                                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                                    "argument": {
                                                                                                                                                                                      "application": {
                                                                                                                                                                                        "function": {
                                                                                                                                                                                          "application": {
                                                                                                                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.gt"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                                                            "argument": {"variable": "lhsarity"}}},
                                                                                                                                                                                        "argument": {"literal": {"integer": {"int32": 1}}}}}}},
                                                                                                                                                                                "argument": {
                                                                                                                                                                                  "application": {
                                                                                                                                                                                    "function": {
                                                                                                                                                                                      "application": {
                                                                                                                                                                                        "function": {"variable": "padn"},
                                                                                                                                                                                        "argument": {
                                                                                                                                                                                          "application": {
                                                                                                                                                                                            "function": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.sub"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                                                                "argument": {"variable": "lhsarity"}}},
                                                                                                                                                                                            "argument": {"literal": {"integer": {"int32": 1}}}}}}},
                                                                                                                                                                                    "argument": {"variable": "a2"}}}}},
                                                                                                                                                                            "argument": {"variable": "a2"}}}}},
                                                                                                                                                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}}}}}}}}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "cases",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "cs",
                                                                                                                        "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                                        "body": {"application": {"function": {"variable": "forCases"}, "argument": {"variable": "cs"}}}}}},
                                                                                                                  {
                                                                                                                    "name": "project",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "p",
                                                                                                                        "domain": {"variable": "hydra.core.model.Projection"},
                                                                                                                        "body": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "either": {
                                                                                                                                    "right": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {"variable": "forNullaryElim"},
                                                                                                                                        "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "project", "term": {"variable": "p"}}}}}}}},
                                                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}}}}},
                                                                                                                  {
                                                                                                                    "name": "unwrap",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "n",
                                                                                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                                                                                        "body": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "either": {
                                                                                                                                    "right": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {"variable": "forNullaryElim"},
                                                                                                                                        "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "unwrap", "term": {"variable": "n"}}}}}}}},
                                                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}}}}},
                                                                                                                  {
                                                                                                                    "name": "lambda",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "l",
                                                                                                                        "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "txl",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"application": {"function": {"variable": "hydra.core.scoping.extendGraphForLambda"}, "argument": {"variable": "tx"}}},
                                                                                                                                    "argument": {"variable": "l"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.eithers.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "argument": {"variable": "unwind"}}},
                                                                                                                                "argument": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "txl"}}},
                                                                                                                                    "argument": {"variable": "term"}}}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "let",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "l",
                                                                                                                        "domain": {"variable": "hydra.core.model.Let"},
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "txlt",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {"variable": "hydra.core.scoping.extendGraphForLet"},
                                                                                                                                            "argument": {
                                                                                                                                              "lambda": {
                                                                                                                                                "parameter": "_",
                                                                                                                                                "domain": {"variable": "hydra.core.graph.Graph"},
                                                                                                                                                "body": {
                                                                                                                                                  "lambda": {
                                                                                                                                                    "parameter": "_",
                                                                                                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                                                    "body": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                                                                                        "argument": {"variable": "tx"}}},
                                                                                                                                    "argument": {"variable": "l"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "txlt"}}},
                                                                                                                                "argument": {"variable": "term"}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "typeApplication",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "tat",
                                                                                                                        "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                                                                                        "body": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"variable": "topLevel"}}},
                                                                                                                                            "argument": {"variable": "forced"}}},
                                                                                                                                        "argument": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                                                "argument": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
                                                                                                                                                    "argument": {"variable": "tat"}}}}},
                                                                                                                                            "argument": {"variable": "typeArgs"}}}}},
                                                                                                                                    "argument": {"variable": "recurse"}}},
                                                                                                                                "argument": {"variable": "tx"}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                                                                                "argument": {"variable": "tat"}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "typeLambda",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "tl",
                                                                                                                        "domain": {"variable": "hydra.core.model.TypeLambda"},
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "txt",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {"function": {"variable": "hydra.core.scoping.extendGraphForTypeLambda"}, "argument": {"variable": "tx"}}},
                                                                                                                                    "argument": {"variable": "tl"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "txt"}}},
                                                                                                                                "argument": {"variable": "term"}}}}}}}}]}},
                                                                                                            "argument": {"variable": "term"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {
                                    "function": {
                                      "domain": {"literal": "boolean"},
                                      "codomain": {
                                        "function": {
                                          "domain": {"literal": "boolean"},
                                          "codomain": {
                                            "function": {
                                              "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                              "codomain": {
                                                "function": {
                                                  "domain": {
                                                    "function": {
                                                      "domain": {"variable": "hydra.core.graph.Graph"},
                                                      "codomain": {
                                                        "function": {
                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                          "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                  "codomain": {
                                                    "function": {
                                                      "domain": {"variable": "hydra.core.graph.Graph"},
                                                      "codomain": {
                                                        "function": {
                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                          "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}}}}}}}}}},
                                  "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {"body": {"variable": "hydra.core.rewriting.rewriteTermWithContextM"}, "type": {"variable": "hydra.core.graph.Graph"}}},
                                            "type": {"variable": "hydra.core.errors.Error"}}},
                                        "argument": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"literal": {"boolean": true}}}},
                                                "argument": {"literal": {"boolean": false}}}},
                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Type"}}}}}}},
                                    "argument": {"variable": "tx0"}}},
                                "argument": {"variable": "term0"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Recursively transform arbitrary terms like 'add 42' into terms like '\\x.add 42 x', eliminating partial application. Variable references are not expanded. This is useful for targets like Python with weaker support for currying than Hydra or Haskell. Note: this is a \"trusty\" function which assumes the graph is well-formed, i.e. no dangling references. It also assumes that type inference has already been performed. After eta expansion, type inference needs to be performed again, as new, untyped lambdas may have been added."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.etaExpansionArity",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"literal": {"integer": "int32"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "term",
                    "domain": {"variable": "hydra.core.model.Term"},
                    "body": {
                      "application": {
                        "function": {
                          "cases": {
                            "typeName": "hydra.core.model.Term",
                            "default": {"literal": {"integer": {"int32": 0}}},
                            "cases": [
                              {
                                "name": "annotated",
                                "handler": {
                                  "lambda": {
                                    "parameter": "at",
                                    "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                    "body": {
                                      "application": {
                                        "function": {"application": {"function": {"variable": "hydra.core.reduction.etaExpansionArity"}, "argument": {"variable": "graph"}}},
                                        "argument": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                            "argument": {"variable": "at"}}}}}}}},
                              {
                                "name": "application",
                                "handler": {
                                  "lambda": {
                                    "parameter": "app",
                                    "domain": {"variable": "hydra.core.model.Application"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.sub"}, "type": {"literal": {"integer": "int32"}}}},
                                            "argument": {
                                              "application": {
                                                "function": {"application": {"function": {"variable": "hydra.core.reduction.etaExpansionArity"}, "argument": {"variable": "graph"}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                    "argument": {"variable": "app"}}}}}}},
                                        "argument": {"literal": {"integer": {"int32": 1}}}}}}}},
                              {
                                "name": "cases",
                                "handler": {
                                  "lambda": {
                                    "parameter": "_",
                                    "domain": {"variable": "hydra.core.model.CaseStatement"},
                                    "body": {"literal": {"integer": {"int32": 1}}}}}},
                              {
                                "name": "lambda",
                                "handler": {
                                  "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Lambda"}, "body": {"literal": {"integer": {"int32": 0}}}}}},
                              {
                                "name": "project",
                                "handler": {
                                  "lambda": {
                                    "parameter": "_",
                                    "domain": {"variable": "hydra.core.model.Projection"},
                                    "body": {"literal": {"integer": {"int32": 1}}}}}},
                              {
                                "name": "unwrap",
                                "handler": {
                                  "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Name"}, "body": {"literal": {"integer": {"int32": 1}}}}}},
                              {
                                "name": "typeLambda",
                                "handler": {
                                  "lambda": {
                                    "parameter": "ta",
                                    "domain": {"variable": "hydra.core.model.TypeLambda"},
                                    "body": {
                                      "application": {
                                        "function": {"application": {"function": {"variable": "hydra.core.reduction.etaExpansionArity"}, "argument": {"variable": "graph"}}},
                                        "argument": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "body"}},
                                            "argument": {"variable": "ta"}}}}}}}},
                              {
                                "name": "typeApplication",
                                "handler": {
                                  "lambda": {
                                    "parameter": "tt",
                                    "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                    "body": {
                                      "application": {
                                        "function": {"application": {"function": {"variable": "hydra.core.reduction.etaExpansionArity"}, "argument": {"variable": "graph"}}},
                                        "argument": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                            "argument": {"variable": "tt"}}}}}}}},
                              {
                                "name": "variable",
                                "handler": {
                                  "lambda": {
                                    "parameter": "name",
                                    "domain": {"variable": "hydra.core.model.Name"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                    "type": {"literal": {"integer": "int32"}}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.bind"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                            "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {"application": {"function": {"variable": "hydra.core.lexical.lookupBinding"}, "argument": {"variable": "graph"}}},
                                                            "argument": {"variable": "name"}}}}},
                                                    "argument": {
                                                      "lambda": {
                                                        "parameter": "b",
                                                        "domain": {"variable": "hydra.core.model.Binding"},
                                                        "body": {
                                                          "application": {
                                                            "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                            "argument": {"variable": "b"}}}}}}}}},
                                            "argument": {"literal": {"integer": {"int32": 0}}}}},
                                        "argument": {
                                          "lambda": {
                                            "parameter": "ts",
                                            "domain": {"variable": "hydra.core.model.TypeScheme"},
                                            "body": {
                                              "application": {
                                                "function": {"variable": "hydra.core.arity.typeArity"},
                                                "argument": {
                                                  "application": {
                                                    "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                                    "argument": {"variable": "ts"}}}}}}}}}}}}]}},
                        "argument": {"variable": "term"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Calculate the arity for eta expansion Note: this is a \"trusty\" function which assumes the graph is well-formed, i.e. no dangling references."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.etaReduceTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Term"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "term",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "noChange",
                        "term": {"variable": "term"},
                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "reduceLambda",
                            "term": {
                              "lambda": {
                                "parameter": "l",
                                "domain": {"variable": "hydra.core.model.Lambda"},
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "v",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
                                            "argument": {"variable": "l"}}},
                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "d",
                                            "term": {
                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "domain"}}, "argument": {"variable": "l"}}},
                                            "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Type"}}, "constraints": []}}],
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "body",
                                                "term": {
                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}},
                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                            "body": {
                                              "application": {
                                                "function": {
                                                  "cases": {
                                                    "typeName": "hydra.core.model.Term",
                                                    "default": {"variable": "noChange"},
                                                    "cases": [
                                                      {
                                                        "name": "annotated",
                                                        "handler": {
                                                          "lambda": {
                                                            "parameter": "at",
                                                            "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                            "body": {
                                                              "application": {
                                                                "function": {"variable": "reduceLambda"},
                                                                "argument": {
                                                                  "record": {
                                                                    "typeName": "hydra.core.model.Lambda",
                                                                    "fields": [
                                                                      {"name": "parameter", "term": {"variable": "v"}},
                                                                      {"name": "domain", "term": {"variable": "d"}},
                                                                      {
                                                                        "name": "body",
                                                                        "term": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                            "argument": {"variable": "at"}}}}]}}}}}}},
                                                      {
                                                        "name": "application",
                                                        "handler": {
                                                          "lambda": {
                                                            "parameter": "app",
                                                            "domain": {"variable": "hydra.core.model.Application"},
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "lhs",
                                                                    "term": {
                                                                      "application": {
                                                                        "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                                        "argument": {"variable": "app"}}},
                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "rhs",
                                                                        "term": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "argument"}},
                                                                            "argument": {"variable": "app"}}},
                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "cases": {
                                                                            "typeName": "hydra.core.model.Term",
                                                                            "default": {"variable": "noChange"},
                                                                            "cases": [
                                                                              {
                                                                                "name": "annotated",
                                                                                "handler": {
                                                                                  "lambda": {
                                                                                    "parameter": "at",
                                                                                    "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {"variable": "reduceLambda"},
                                                                                        "argument": {
                                                                                          "record": {
                                                                                            "typeName": "hydra.core.model.Lambda",
                                                                                            "fields": [
                                                                                              {"name": "parameter", "term": {"variable": "v"}},
                                                                                              {"name": "domain", "term": {"variable": "d"}},
                                                                                              {
                                                                                                "name": "body",
                                                                                                "term": {
                                                                                                  "inject": {
                                                                                                    "typeName": "hydra.core.model.Term",
                                                                                                    "field": {
                                                                                                      "name": "application",
                                                                                                      "term": {
                                                                                                        "record": {
                                                                                                          "typeName": "hydra.core.model.Application",
                                                                                                          "fields": [
                                                                                                            {"name": "function", "term": {"variable": "lhs"}},
                                                                                                            {
                                                                                                              "name": "argument",
                                                                                                              "term": {
                                                                                                                "application": {
                                                                                                                  "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                                                                  "argument": {"variable": "at"}}}}]}}}}}}]}}}}}}},
                                                                              {
                                                                                "name": "variable",
                                                                                "handler": {
                                                                                  "lambda": {
                                                                                    "parameter": "v1",
                                                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "hydra.core.lib.logic.and"},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": "string"}}},
                                                                                                                "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "v"}}}}},
                                                                                                            "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "v1"}}}}}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"variable": "hydra.core.lib.logic.not"},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {"application": {"function": {"variable": "hydra.core.variables.isFreeVariableInTerm"}, "argument": {"variable": "v"}}},
                                                                                                            "argument": {"variable": "lhs"}}}}}}}}},
                                                                                            "argument": {"application": {"function": {"variable": "hydra.core.reduction.etaReduceTerm"}, "argument": {"variable": "lhs"}}}}},
                                                                                        "argument": {"variable": "noChange"}}}}}}]}},
                                                                        "argument": {"application": {"function": {"variable": "hydra.core.reduction.etaReduceTerm"}, "argument": {"variable": "rhs"}}}}}}}}}}}}]}},
                                                "argument": {"application": {"function": {"variable": "hydra.core.reduction.etaReduceTerm"}, "argument": {"variable": "body"}}}}}}}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {"function": {"domain": {"variable": "hydra.core.model.Lambda"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                              "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "cases": {
                                "typeName": "hydra.core.model.Term",
                                "default": {"variable": "noChange"},
                                "cases": [
                                  {
                                    "name": "annotated",
                                    "handler": {
                                      "lambda": {
                                        "parameter": "at",
                                        "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                        "body": {
                                          "inject": {
                                            "typeName": "hydra.core.model.Term",
                                            "field": {
                                              "name": "annotated",
                                              "term": {
                                                "record": {
                                                  "typeName": "hydra.core.model.AnnotatedTerm",
                                                  "fields": [
                                                    {
                                                      "name": "body",
                                                      "term": {
                                                        "application": {
                                                          "function": {"variable": "hydra.core.reduction.etaReduceTerm"},
                                                          "argument": {
                                                            "application": {
                                                              "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                              "argument": {"variable": "at"}}}}}},
                                                    {
                                                      "name": "annotation",
                                                      "term": {
                                                        "application": {
                                                          "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "annotation"}},
                                                          "argument": {"variable": "at"}}}}]}}}}}}}},
                                  {
                                    "name": "lambda",
                                    "handler": {
                                      "lambda": {
                                        "parameter": "l",
                                        "domain": {"variable": "hydra.core.model.Lambda"},
                                        "body": {"application": {"function": {"variable": "reduceLambda"}, "argument": {"variable": "l"}}}}}}]}},
                            "argument": {"variable": "term"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Eta-reduce a term by removing redundant lambda abstractions"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.reduceTerm",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg2", "type": {"literal": "boolean"}, "isLazy": false},
            {"name": "arg3", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "cx",
                    "domain": {"variable": "t0"},
                    "body": {
                      "lambda": {
                        "parameter": "graph",
                        "domain": {"variable": "hydra.core.graph.Graph"},
                        "body": {
                          "lambda": {
                            "parameter": "eager",
                            "domain": {"literal": "boolean"},
                            "body": {
                              "lambda": {
                                "parameter": "term",
                                "domain": {"variable": "hydra.core.model.Term"},
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "reduce",
                                        "term": {
                                          "lambda": {
                                            "parameter": "eager",
                                            "domain": {"literal": "boolean"},
                                            "body": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.reduction.reduceTerm"}, "type": {"variable": "t0"}}},
                                                        "argument": {"variable": "cx"}}},
                                                    "argument": {"variable": "graph"}}},
                                                "argument": {"variable": "eager"}}}}},
                                        "typeScheme": {
                                          "variables": [],
                                          "body": {
                                            "function": {
                                              "domain": {"literal": "boolean"},
                                              "codomain": {
                                                "function": {
                                                  "domain": {"variable": "hydra.core.model.Term"},
                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                          "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "doRecurse",
                                            "term": {
                                              "lambda": {
                                                "parameter": "eager",
                                                "domain": {"literal": "boolean"},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "term",
                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "isNonLambdaTerm",
                                                            "term": {
                                                              "application": {
                                                                "function": {
                                                                  "cases": {
                                                                    "typeName": "hydra.core.model.Term",
                                                                    "default": {"literal": {"boolean": true}},
                                                                    "cases": [
                                                                      {
                                                                        "name": "lambda",
                                                                        "handler": {
                                                                          "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Lambda"}, "body": {"literal": {"boolean": false}}}}},
                                                                      {
                                                                        "name": "let",
                                                                        "handler": {"lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Let"}, "body": {"literal": {"boolean": false}}}}}]}},
                                                                "argument": {"variable": "term"}}},
                                                            "typeScheme": {"variables": [], "body": {"literal": "boolean"}, "constraints": []}}],
                                                        "body": {
                                                          "application": {
                                                            "function": {"application": {"function": {"variable": "hydra.core.lib.logic.and"}, "argument": {"variable": "eager"}}},
                                                            "argument": {"variable": "isNonLambdaTerm"}}}}}}}}},
                                            "typeScheme": {
                                              "variables": [],
                                              "body": {
                                                "function": {
                                                  "domain": {"literal": "boolean"},
                                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"literal": "boolean"}}}}},
                                              "constraints": []}}],
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "reduceArg",
                                                "term": {
                                                  "lambda": {
                                                    "parameter": "eager",
                                                    "domain": {"literal": "boolean"},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "arg",
                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "typeApplication": {
                                                                        "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                    "argument": {"variable": "eager"}}},
                                                                "argument": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {"body": {"either": {"right": {"variable": "arg"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                    "type": {"variable": "hydra.core.model.Term"}}}}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"application": {"function": {"variable": "reduce"}, "argument": {"literal": {"boolean": false}}}},
                                                                "argument": {"variable": "arg"}}}}}}}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {
                                                    "function": {
                                                      "domain": {"literal": "boolean"},
                                                      "codomain": {
                                                        "function": {
                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                          "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "applyToArguments",
                                                    "term": {
                                                      "lambda": {
                                                        "parameter": "fun",
                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                        "body": {
                                                          "lambda": {
                                                            "parameter": "args",
                                                            "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {
                                                                              "typeApplication": {
                                                                                "body": {"variable": "hydra.core.lib.optionals.match"},
                                                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}}}},
                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.uncons"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                            "argument": {"variable": "args"}}}}},
                                                                    "argument": {"variable": "fun"}}},
                                                                "argument": {
                                                                  "lambda": {
                                                                    "parameter": "uc",
                                                                    "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {"variable": "applyToArguments"},
                                                                            "argument": {
                                                                              "inject": {
                                                                                "typeName": "hydra.core.model.Term",
                                                                                "field": {
                                                                                  "name": "application",
                                                                                  "term": {
                                                                                    "record": {
                                                                                      "typeName": "hydra.core.model.Application",
                                                                                      "fields": [
                                                                                        {"name": "function", "term": {"variable": "fun"}},
                                                                                        {
                                                                                          "name": "argument",
                                                                                          "term": {
                                                                                            "application": {
                                                                                              "function": {
                                                                                                "typeApplication": {
                                                                                                  "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                  "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                              "argument": {"variable": "uc"}}}}]}}}}}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                            "argument": {"variable": "uc"}}}}}}}}}}}}},
                                                    "typeScheme": {
                                                      "variables": [],
                                                      "body": {
                                                        "function": {
                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                          "codomain": {
                                                            "function": {"domain": {"list": {"variable": "hydra.core.model.Term"}}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                                      "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "mapErrorToString",
                                                        "term": {
                                                          "lambda": {
                                                            "parameter": "e",
                                                            "domain": {"variable": "hydra.core.errors.Error"},
                                                            "body": {
                                                              "inject": {
                                                                "typeName": "hydra.core.errors.Error",
                                                                "field": {
                                                                  "name": "other",
                                                                  "term": {
                                                                    "wrap": {
                                                                      "typeName": "hydra.core.errors.OtherError",
                                                                      "body": {"application": {"function": {"variable": "hydra.core.print.errors.error"}, "argument": {"variable": "e"}}}}}}}}}},
                                                        "typeScheme": {
                                                          "variables": [],
                                                          "body": {"function": {"domain": {"variable": "hydra.core.errors.Error"}, "codomain": {"variable": "hydra.core.errors.Error"}}},
                                                          "constraints": []}}],
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "applyProjection",
                                                            "term": {
                                                              "lambda": {
                                                                "parameter": "proj",
                                                                "domain": {"variable": "hydra.core.model.Projection"},
                                                                "body": {
                                                                  "lambda": {
                                                                    "parameter": "reducedArg",
                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                    "type": {"list": {"variable": "hydra.core.model.Field"}}}},
                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {"variable": "hydra.core.extract.model.record"},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {"project": {"typeName": "hydra.core.model.Projection", "fieldName": "typeName"}},
                                                                                            "argument": {"variable": "proj"}}}}},
                                                                                    "argument": {"variable": "graph"}}},
                                                                                "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "reducedArg"}}}}}}},
                                                                        "argument": {
                                                                          "lambda": {
                                                                            "parameter": "fields",
                                                                            "domain": {"list": {"variable": "hydra.core.model.Field"}},
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "matching",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.find"}, "type": {"variable": "hydra.core.model.Field"}}},
                                                                                            "argument": {
                                                                                              "lambda": {
                                                                                                "parameter": "f",
                                                                                                "domain": {"variable": "hydra.core.model.Field"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                        "argument": {
                                                                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "name"}}, "argument": {"variable": "f"}}}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.Projection", "fieldName": "fieldName"}},
                                                                                                        "argument": {"variable": "proj"}}}}}}}}},
                                                                                        "argument": {"variable": "fields"}}},
                                                                                    "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Field"}}, "constraints": []}}],
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Field"}}},
                                                                                                "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                            "argument": {"variable": "matching"}}},
                                                                                        "argument": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "either": {
                                                                                                    "left": {
                                                                                                      "inject": {
                                                                                                        "typeName": "hydra.core.errors.Error",
                                                                                                        "field": {
                                                                                                          "name": "resolution",
                                                                                                          "term": {
                                                                                                            "inject": {
                                                                                                              "typeName": "hydra.core.errors.ResolutionError",
                                                                                                              "field": {
                                                                                                                "name": "noMatchingField",
                                                                                                                "term": {
                                                                                                                  "record": {
                                                                                                                    "typeName": "hydra.core.errors.NoMatchingFieldError",
                                                                                                                    "fields": [
                                                                                                                      {
                                                                                                                        "name": "fieldName",
                                                                                                                        "term": {
                                                                                                                          "application": {
                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.Projection", "fieldName": "fieldName"}},
                                                                                                                            "argument": {"variable": "proj"}}}}]}}}}}}}}}},
                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                            "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                    "argument": {
                                                                                      "lambda": {
                                                                                        "parameter": "mf",
                                                                                        "domain": {"variable": "hydra.core.model.Field"},
                                                                                        "body": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "either": {
                                                                                                    "right": {
                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "term"}}, "argument": {"variable": "mf"}}}}},
                                                                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                            "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}}}}}}}},
                                                            "typeScheme": {
                                                              "variables": [],
                                                              "body": {
                                                                "function": {
                                                                  "domain": {"variable": "hydra.core.model.Projection"},
                                                                  "codomain": {
                                                                    "function": {
                                                                      "domain": {"variable": "hydra.core.model.Term"},
                                                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                              "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "applyCases",
                                                                "term": {
                                                                  "lambda": {
                                                                    "parameter": "cs",
                                                                    "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                    "body": {
                                                                      "lambda": {
                                                                        "parameter": "reducedArg",
                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                        "type": {"variable": "hydra.core.model.Field"}}},
                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {"variable": "hydra.core.extract.model.injection"},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "typeName"}},
                                                                                                "argument": {"variable": "cs"}}}}},
                                                                                        "argument": {"variable": "graph"}}},
                                                                                    "argument": {"variable": "reducedArg"}}}}},
                                                                            "argument": {
                                                                              "lambda": {
                                                                                "parameter": "field",
                                                                                "domain": {"variable": "hydra.core.model.Field"},
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "matching",
                                                                                        "term": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.find"}, "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                "argument": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "f",
                                                                                                    "domain": {"variable": "hydra.core.model.CaseAlternative"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "argument": {
                                                                                                              "application": {
                                                                                                                "function": {"project": {"typeName": "hydra.core.model.CaseAlternative", "fieldName": "name"}},
                                                                                                                "argument": {"variable": "f"}}}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "name"}},
                                                                                                            "argument": {"variable": "field"}}}}}}}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "cases"}},
                                                                                                "argument": {"variable": "cs"}}}}},
                                                                                        "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.CaseAlternative"}}, "constraints": []}}],
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                                                                    "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                "argument": {"variable": "matching"}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                            "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "default"}},
                                                                                                            "argument": {"variable": "cs"}}}}},
                                                                                                    "argument": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "either": {
                                                                                                                "left": {
                                                                                                                  "inject": {
                                                                                                                    "typeName": "hydra.core.errors.Error",
                                                                                                                    "field": {
                                                                                                                      "name": "resolution",
                                                                                                                      "term": {
                                                                                                                        "inject": {
                                                                                                                          "typeName": "hydra.core.errors.ResolutionError",
                                                                                                                          "field": {
                                                                                                                            "name": "noMatchingField",
                                                                                                                            "term": {
                                                                                                                              "record": {
                                                                                                                                "typeName": "hydra.core.errors.NoMatchingFieldError",
                                                                                                                                "fields": [
                                                                                                                                  {
                                                                                                                                    "name": "fieldName",
                                                                                                                                    "term": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "name"}},
                                                                                                                                        "argument": {"variable": "field"}}}}]}}}}}}}}}},
                                                                                                            "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                        "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                "argument": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "x",
                                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                                    "body": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"typeApplication": {"body": {"either": {"right": {"variable": "x"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                        "type": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                                        "argument": {
                                                                                          "lambda": {
                                                                                            "parameter": "mf",
                                                                                            "domain": {"variable": "hydra.core.model.CaseAlternative"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "application",
                                                                                                              "term": {
                                                                                                                "record": {
                                                                                                                  "typeName": "hydra.core.model.Application",
                                                                                                                  "fields": [
                                                                                                                    {
                                                                                                                      "name": "function",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"project": {"typeName": "hydra.core.model.CaseAlternative", "fieldName": "handler"}},
                                                                                                                          "argument": {"variable": "mf"}}}},
                                                                                                                    {
                                                                                                                      "name": "argument",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "term"}},
                                                                                                                          "argument": {"variable": "field"}}}}]}}}}}}},
                                                                                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}}}}}}}},
                                                                "typeScheme": {
                                                                  "variables": [],
                                                                  "body": {
                                                                    "function": {
                                                                      "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                      "codomain": {
                                                                        "function": {
                                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                                          "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                  "constraints": []}}],
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "applyIfNullary",
                                                                    "term": {
                                                                      "lambda": {
                                                                        "parameter": "eager",
                                                                        "domain": {"literal": "boolean"},
                                                                        "body": {
                                                                          "lambda": {
                                                                            "parameter": "original",
                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                            "body": {
                                                                              "lambda": {
                                                                                "parameter": "args",
                                                                                "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "stripped",
                                                                                        "term": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "original"}}},
                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                    "body": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "forProjection",
                                                                                            "term": {
                                                                                              "lambda": {
                                                                                                "parameter": "proj",
                                                                                                "domain": {"variable": "hydra.core.model.Projection"},
                                                                                                "body": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "args",
                                                                                                    "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {"variable": "hydra.core.lib.optionals.match"},
                                                                                                                        "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}}}},
                                                                                                                    "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.uncons"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                    "argument": {"variable": "args"}}}}},
                                                                                                            "argument": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {"body": {"either": {"right": {"variable": "original"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                        "argument": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "uc",
                                                                                                            "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                            "body": {
                                                                                                              "let": {
                                                                                                                "bindings": [
                                                                                                                  {
                                                                                                                    "name": "arg",
                                                                                                                    "term": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                        "argument": {"variable": "uc"}}},
                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                "body": {
                                                                                                                  "let": {
                                                                                                                    "bindings": [
                                                                                                                      {
                                                                                                                        "name": "remainingArgs",
                                                                                                                        "term": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                            "argument": {"variable": "uc"}}},
                                                                                                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                                                                                    "body": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "reduceArg"}, "argument": {"variable": "eager"}}},
                                                                                                                                "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "arg"}}}}}}},
                                                                                                                        "argument": {
                                                                                                                          "lambda": {
                                                                                                                            "parameter": "reducedArg",
                                                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                            "body": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "typeApplication": {
                                                                                                                                                "body": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                            "argument": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {"application": {"function": {"variable": "applyProjection"}, "argument": {"variable": "proj"}}},
                                                                                                                                                "argument": {"variable": "reducedArg"}}}}},
                                                                                                                                        "argument": {"application": {"function": {"variable": "reduce"}, "argument": {"variable": "eager"}}}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "lambda": {
                                                                                                                                    "parameter": "reducedResult",
                                                                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                    "body": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                                                            "argument": {"variable": "reducedResult"}}},
                                                                                                                                        "argument": {"variable": "remainingArgs"}}}}}}}}}}}}}}}}}}}}}}},
                                                                                            "typeScheme": {
                                                                                              "variables": [],
                                                                                              "body": {
                                                                                                "function": {
                                                                                                  "domain": {"variable": "hydra.core.model.Projection"},
                                                                                                  "codomain": {
                                                                                                    "function": {
                                                                                                      "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                                              "constraints": []}}],
                                                                                        "body": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "forCases",
                                                                                                "term": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "cs",
                                                                                                    "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                    "body": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "args",
                                                                                                        "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                        "body": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {"variable": "hydra.core.lib.optionals.match"},
                                                                                                                            "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}}}},
                                                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.uncons"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                        "argument": {"variable": "args"}}}}},
                                                                                                                "argument": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {
                                                                                                                      "typeApplication": {"body": {"either": {"right": {"variable": "original"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                            "argument": {
                                                                                                              "lambda": {
                                                                                                                "parameter": "uc",
                                                                                                                "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                "body": {
                                                                                                                  "let": {
                                                                                                                    "bindings": [
                                                                                                                      {
                                                                                                                        "name": "arg",
                                                                                                                        "term": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                            "argument": {"variable": "uc"}}},
                                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                    "body": {
                                                                                                                      "let": {
                                                                                                                        "bindings": [
                                                                                                                          {
                                                                                                                            "name": "remainingArgs",
                                                                                                                            "term": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                    "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                                "argument": {"variable": "uc"}}},
                                                                                                                            "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                                                                                        "body": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                "argument": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"application": {"function": {"variable": "reduceArg"}, "argument": {"variable": "eager"}}},
                                                                                                                                    "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "arg"}}}}}}},
                                                                                                                            "argument": {
                                                                                                                              "lambda": {
                                                                                                                                "parameter": "reducedArg",
                                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                "body": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {
                                                                                                                                                "body": {
                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {
                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                "argument": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {"application": {"function": {"variable": "applyCases"}, "argument": {"variable": "cs"}}},
                                                                                                                                                    "argument": {"variable": "reducedArg"}}}}},
                                                                                                                                            "argument": {"application": {"function": {"variable": "reduce"}, "argument": {"variable": "eager"}}}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "lambda": {
                                                                                                                                        "parameter": "reducedResult",
                                                                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                        "body": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                                                                "argument": {"variable": "reducedResult"}}},
                                                                                                                                            "argument": {"variable": "remainingArgs"}}}}}}}}}}}}}}}}}}}}}}},
                                                                                                "typeScheme": {
                                                                                                  "variables": [],
                                                                                                  "body": {
                                                                                                    "function": {
                                                                                                      "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                      "codomain": {
                                                                                                        "function": {
                                                                                                          "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                          "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                                                  "constraints": []}}],
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "forUnwrap",
                                                                                                    "term": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "name",
                                                                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                                                                        "body": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "args",
                                                                                                            "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                            "body": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "typeApplication": {
                                                                                                                            "body": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {"variable": "hydra.core.lib.optionals.match"},
                                                                                                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}}}},
                                                                                                                            "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.uncons"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                            "argument": {"variable": "args"}}}}},
                                                                                                                    "argument": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {
                                                                                                                          "typeApplication": {"body": {"either": {"right": {"variable": "original"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                "argument": {
                                                                                                                  "lambda": {
                                                                                                                    "parameter": "uc",
                                                                                                                    "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                    "body": {
                                                                                                                      "let": {
                                                                                                                        "bindings": [
                                                                                                                          {
                                                                                                                            "name": "arg",
                                                                                                                            "term": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                    "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                                "argument": {"variable": "uc"}}},
                                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "remainingArgs",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                                    "argument": {"variable": "uc"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {"application": {"function": {"variable": "reduceArg"}, "argument": {"variable": "eager"}}},
                                                                                                                                        "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "arg"}}}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "lambda": {
                                                                                                                                    "parameter": "reducedArg",
                                                                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                    "body": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "typeApplication": {
                                                                                                                                                "body": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                            "argument": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {
                                                                                                                                                          "typeApplication": {
                                                                                                                                                            "body": {
                                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                    "argument": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {"application": {"function": {"variable": "hydra.core.extract.model.wrap"}, "argument": {"variable": "name"}}},
                                                                                                                                                            "argument": {"variable": "graph"}}},
                                                                                                                                                        "argument": {"variable": "reducedArg"}}}}},
                                                                                                                                                "argument": {"application": {"function": {"variable": "reduce"}, "argument": {"variable": "eager"}}}}}}},
                                                                                                                                        "argument": {
                                                                                                                                          "lambda": {
                                                                                                                                            "parameter": "reducedResult",
                                                                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                            "body": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                                                                    "argument": {"variable": "reducedResult"}}},
                                                                                                                                                "argument": {"variable": "remainingArgs"}}}}}}}}}}}}}}}}}}}}}}},
                                                                                                    "typeScheme": {
                                                                                                      "variables": [],
                                                                                                      "body": {
                                                                                                        "function": {
                                                                                                          "domain": {"variable": "hydra.core.model.Name"},
                                                                                                          "codomain": {
                                                                                                            "function": {
                                                                                                              "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                              "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                                                      "constraints": []}}],
                                                                                                "body": {
                                                                                                  "let": {
                                                                                                    "bindings": [
                                                                                                      {
                                                                                                        "name": "forLambda",
                                                                                                        "term": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "l",
                                                                                                            "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                                            "body": {
                                                                                                              "lambda": {
                                                                                                                "parameter": "args",
                                                                                                                "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                                "body": {
                                                                                                                  "let": {
                                                                                                                    "bindings": [
                                                                                                                      {
                                                                                                                        "name": "param",
                                                                                                                        "term": {
                                                                                                                          "application": {
                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
                                                                                                                            "argument": {"variable": "l"}}},
                                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                                                    "body": {
                                                                                                                      "let": {
                                                                                                                        "bindings": [
                                                                                                                          {
                                                                                                                            "name": "body",
                                                                                                                            "term": {
                                                                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}},
                                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                        "body": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {"variable": "hydra.core.lib.optionals.match"},
                                                                                                                                            "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}}}},
                                                                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.uncons"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {"variable": "args"}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {"body": {"either": {"right": {"variable": "original"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                            "argument": {
                                                                                                                              "lambda": {
                                                                                                                                "parameter": "uc",
                                                                                                                                "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                                "body": {
                                                                                                                                  "let": {
                                                                                                                                    "bindings": [
                                                                                                                                      {
                                                                                                                                        "name": "arg",
                                                                                                                                        "term": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "typeApplication": {
                                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                                            "argument": {"variable": "uc"}}},
                                                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                                    "body": {
                                                                                                                                      "let": {
                                                                                                                                        "bindings": [
                                                                                                                                          {
                                                                                                                                            "name": "remainingArgs",
                                                                                                                                            "term": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                    "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                                                "argument": {"variable": "uc"}}},
                                                                                                                                            "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                                                                                                        "body": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {
                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                "argument": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {"application": {"function": {"variable": "reduce"}, "argument": {"variable": "eager"}}},
                                                                                                                                                    "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "arg"}}}}}}},
                                                                                                                                            "argument": {
                                                                                                                                              "lambda": {
                                                                                                                                                "parameter": "reducedArg",
                                                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                "body": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "typeApplication": {
                                                                                                                                                            "body": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {
                                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                        "argument": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {"application": {"function": {"variable": "reduce"}, "argument": {"variable": "eager"}}},
                                                                                                                                                            "argument": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {
                                                                                                                                                                      "application": {"function": {"variable": "hydra.core.variables.replaceFreeTermVariable"}, "argument": {"variable": "param"}}},
                                                                                                                                                                    "argument": {"variable": "reducedArg"}}},
                                                                                                                                                                "argument": {"variable": "body"}}}}}}},
                                                                                                                                                    "argument": {
                                                                                                                                                      "lambda": {
                                                                                                                                                        "parameter": "reducedResult",
                                                                                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                        "body": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                                                                                "argument": {"variable": "reducedResult"}}},
                                                                                                                                                            "argument": {"variable": "remainingArgs"}}}}}}}}}}}}}}}}}}}}}}}}}}},
                                                                                                        "typeScheme": {
                                                                                                          "variables": [],
                                                                                                          "body": {
                                                                                                            "function": {
                                                                                                              "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                                              "codomain": {
                                                                                                                "function": {
                                                                                                                  "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                                                          "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "forPrimitive",
                                                                                                            "term": {
                                                                                                              "lambda": {
                                                                                                                "parameter": "prim",
                                                                                                                "domain": {"variable": "hydra.core.graph.Primitive"},
                                                                                                                "body": {
                                                                                                                  "lambda": {
                                                                                                                    "parameter": "arity",
                                                                                                                    "domain": {"literal": {"integer": "int32"}},
                                                                                                                    "body": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "args",
                                                                                                                        "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "argList",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.take"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {"variable": "arity"}}},
                                                                                                                                    "argument": {"variable": "args"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "let": {
                                                                                                                                "bindings": [
                                                                                                                                  {
                                                                                                                                    "name": "remainingArgs",
                                                                                                                                    "term": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.drop"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                            "argument": {"variable": "arity"}}},
                                                                                                                                        "argument": {"variable": "args"}}},
                                                                                                                                    "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                                                                                                "body": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {
                                                                                                                                                "body": {
                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {
                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.mapList"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                "argument": {"application": {"function": {"variable": "reduceArg"}, "argument": {"variable": "eager"}}}}},
                                                                                                                                            "argument": {"variable": "argList"}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "lambda": {
                                                                                                                                        "parameter": "reducedArgs",
                                                                                                                                        "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                                                        "body": {
                                                                                                                                          "let": {
                                                                                                                                            "bindings": [
                                                                                                                                              {
                                                                                                                                                "name": "strippedArgs",
                                                                                                                                                "term": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "typeApplication": {
                                                                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                        "argument": {"variable": "hydra.core.strip.deannotateTerm"}}},
                                                                                                                                                    "argument": {"variable": "reducedArgs"}}},
                                                                                                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                                                                                                            "body": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {
                                                                                                                                                          "typeApplication": {
                                                                                                                                                            "body": {
                                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                    "argument": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                    "body": {
                                                                                                                                                                      "typeApplication": {
                                                                                                                                                                        "body": {
                                                                                                                                                                          "typeApplication": {
                                                                                                                                                                            "body": {
                                                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bimap"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                "argument": {"variable": "mapErrorToString"}}},
                                                                                                                                                            "argument": {"lambda": {"parameter": "x", "domain": {"variable": "hydra.core.model.Term"}, "body": {"variable": "x"}}}}},
                                                                                                                                                        "argument": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {"project": {"typeName": "hydra.core.graph.Primitive", "fieldName": "implementation"}},
                                                                                                                                                                    "argument": {"variable": "prim"}}},
                                                                                                                                                                "argument": {"variable": "graph"}}},
                                                                                                                                                            "argument": {"variable": "strippedArgs"}}}}}}},
                                                                                                                                                "argument": {
                                                                                                                                                  "lambda": {
                                                                                                                                                    "parameter": "primResult",
                                                                                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                    "body": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {
                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                    "body": {
                                                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                            "argument": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {"application": {"function": {"variable": "reduce"}, "argument": {"variable": "eager"}}},
                                                                                                                                                                "argument": {"variable": "primResult"}}}}},
                                                                                                                                                        "argument": {
                                                                                                                                                          "lambda": {
                                                                                                                                                            "parameter": "reducedResult",
                                                                                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                            "body": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                                                                                    "argument": {"variable": "reducedResult"}}},
                                                                                                                                                                "argument": {"variable": "remainingArgs"}}}}}}}}}}}}}}}}}}}}}}}}}}},
                                                                                                            "typeScheme": {
                                                                                                              "variables": [],
                                                                                                              "body": {
                                                                                                                "function": {
                                                                                                                  "domain": {"variable": "hydra.core.graph.Primitive"},
                                                                                                                  "codomain": {
                                                                                                                    "function": {
                                                                                                                      "domain": {"literal": {"integer": "int32"}},
                                                                                                                      "codomain": {
                                                                                                                        "function": {
                                                                                                                          "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                                                          "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                                                              "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "cases": {
                                                                                                                "typeName": "hydra.core.model.Term",
                                                                                                                "default": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {
                                                                                                                          "either": {
                                                                                                                            "right": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "applyToArguments"}, "argument": {"variable": "original"}}},
                                                                                                                                "argument": {"variable": "args"}}}}},
                                                                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                "cases": [
                                                                                                                  {
                                                                                                                    "name": "application",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "app",
                                                                                                                        "domain": {"variable": "hydra.core.model.Application"},
                                                                                                                        "body": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                                                "argument": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                                                                                                    "argument": {"variable": "app"}}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "argument"}},
                                                                                                                                        "argument": {"variable": "app"}}}}},
                                                                                                                                "argument": {"variable": "args"}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "cases",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "cs",
                                                                                                                        "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                                                                        "body": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.isEmpty"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {"variable": "args"}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {"body": {"either": {"right": {"variable": "original"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "forCases"}, "argument": {"variable": "cs"}}},
                                                                                                                                "argument": {"variable": "args"}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "project",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "p",
                                                                                                                        "domain": {"variable": "hydra.core.model.Projection"},
                                                                                                                        "body": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.isEmpty"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {"variable": "args"}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {"body": {"either": {"right": {"variable": "original"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "forProjection"}, "argument": {"variable": "p"}}},
                                                                                                                                "argument": {"variable": "args"}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "unwrap",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "n",
                                                                                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                                                                                        "body": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.isEmpty"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {"variable": "args"}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {"body": {"either": {"right": {"variable": "original"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "forUnwrap"}, "argument": {"variable": "n"}}},
                                                                                                                                "argument": {"variable": "args"}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "lambda",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "l",
                                                                                                                        "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                                                        "body": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.isEmpty"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                        "argument": {"variable": "args"}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {
                                                                                                                                      "typeApplication": {"body": {"either": {"right": {"variable": "original"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {"application": {"function": {"variable": "forLambda"}, "argument": {"variable": "l"}}},
                                                                                                                                "argument": {"variable": "args"}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "variable",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "v",
                                                                                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "mBinding",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"application": {"function": {"variable": "hydra.core.lexical.lookupBinding"}, "argument": {"variable": "graph"}}},
                                                                                                                                    "argument": {"variable": "v"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                            "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                        "argument": {"variable": "mBinding"}}},
                                                                                                                                    "argument": {
                                                                                                                                      "let": {
                                                                                                                                        "bindings": [
                                                                                                                                          {
                                                                                                                                            "name": "mPrim",
                                                                                                                                            "term": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {"application": {"function": {"variable": "hydra.core.lexical.lookupPrimitive"}, "argument": {"variable": "graph"}}},
                                                                                                                                                "argument": {"variable": "v"}}},
                                                                                                                                            "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.graph.Primitive"}}, "constraints": []}}],
                                                                                                                                        "body": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {
                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.graph.Primitive"}}},
                                                                                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                                    "argument": {"variable": "mPrim"}}},
                                                                                                                                                "argument": {
                                                                                                                                                  "typeApplication": {
                                                                                                                                                    "body": {
                                                                                                                                                      "typeApplication": {
                                                                                                                                                        "body": {
                                                                                                                                                          "either": {
                                                                                                                                                            "right": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {"application": {"function": {"variable": "applyToArguments"}, "argument": {"variable": "original"}}},
                                                                                                                                                                "argument": {"variable": "args"}}}}},
                                                                                                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                            "argument": {
                                                                                                                                              "lambda": {
                                                                                                                                                "parameter": "prim",
                                                                                                                                                "domain": {"variable": "hydra.core.graph.Primitive"},
                                                                                                                                                "body": {
                                                                                                                                                  "let": {
                                                                                                                                                    "bindings": [
                                                                                                                                                      {
                                                                                                                                                        "name": "arity",
                                                                                                                                                        "term": {"application": {"function": {"variable": "hydra.core.arity.primitiveArity"}, "argument": {"variable": "prim"}}},
                                                                                                                                                        "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                                                                                                    "body": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                    "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                                                                    "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                                                "argument": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {
                                                                                                                                                                      "application": {
                                                                                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.gt"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                                        "argument": {"variable": "arity"}}},
                                                                                                                                                                    "argument": {
                                                                                                                                                                      "application": {
                                                                                                                                                                        "function": {
                                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                        "argument": {"variable": "args"}}}}}}},
                                                                                                                                                            "argument": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {
                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                    "body": {
                                                                                                                                                                      "either": {
                                                                                                                                                                        "right": {
                                                                                                                                                                          "application": {
                                                                                                                                                                            "function": {"application": {"function": {"variable": "applyToArguments"}, "argument": {"variable": "original"}}},
                                                                                                                                                                            "argument": {"variable": "args"}}}}},
                                                                                                                                                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                                "type": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                                        "argument": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {"application": {"function": {"variable": "forPrimitive"}, "argument": {"variable": "prim"}}},
                                                                                                                                                                "argument": {"variable": "arity"}}},
                                                                                                                                                            "argument": {"variable": "args"}}}}}}}}}}}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "lambda": {
                                                                                                                                    "parameter": "binding",
                                                                                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                                    "body": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                                                            "argument": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}},
                                                                                                                                                "argument": {"variable": "binding"}}}}},
                                                                                                                                        "argument": {"variable": "args"}}}}}}}}}}}},
                                                                                                                  {
                                                                                                                    "name": "let",
                                                                                                                    "handler": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "lt",
                                                                                                                        "domain": {"variable": "hydra.core.model.Let"},
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "bindings",
                                                                                                                                "term": {
                                                                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "lt"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "let": {
                                                                                                                                "bindings": [
                                                                                                                                  {
                                                                                                                                    "name": "body",
                                                                                                                                    "term": {
                                                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "lt"}}},
                                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                                "body": {
                                                                                                                                  "let": {
                                                                                                                                    "bindings": [
                                                                                                                                      {
                                                                                                                                        "name": "letExpr",
                                                                                                                                        "term": {
                                                                                                                                          "lambda": {
                                                                                                                                            "parameter": "b",
                                                                                                                                            "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                                            "body": {
                                                                                                                                              "inject": {
                                                                                                                                                "typeName": "hydra.core.model.Term",
                                                                                                                                                "field": {
                                                                                                                                                  "name": "let",
                                                                                                                                                  "term": {
                                                                                                                                                    "record": {
                                                                                                                                                      "typeName": "hydra.core.model.Let",
                                                                                                                                                      "fields": [
                                                                                                                                                        {"name": "bindings", "term": {"list": [{"variable": "b"}]}},
                                                                                                                                                        {
                                                                                                                                                          "name": "body",
                                                                                                                                                          "term": {
                                                                                                                                                            "inject": {
                                                                                                                                                              "typeName": "hydra.core.model.Term",
                                                                                                                                                              "field": {
                                                                                                                                                                "name": "variable",
                                                                                                                                                                "term": {
                                                                                                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}}}}}]}}}}}}},
                                                                                                                                        "typeScheme": {
                                                                                                                                          "variables": [],
                                                                                                                                          "body": {"function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                          "constraints": []}}],
                                                                                                                                    "body": {
                                                                                                                                      "let": {
                                                                                                                                        "bindings": [
                                                                                                                                          {
                                                                                                                                            "name": "expandBinding",
                                                                                                                                            "term": {
                                                                                                                                              "lambda": {
                                                                                                                                                "parameter": "b",
                                                                                                                                                "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                                                "body": {
                                                                                                                                                  "record": {
                                                                                                                                                    "typeName": "hydra.core.model.Binding",
                                                                                                                                                    "fields": [
                                                                                                                                                      {
                                                                                                                                                        "name": "name",
                                                                                                                                                        "term": {
                                                                                                                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}},
                                                                                                                                                      {
                                                                                                                                                        "name": "term",
                                                                                                                                                        "term": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {"variable": "hydra.core.variables.replaceFreeTermVariable"},
                                                                                                                                                                    "argument": {
                                                                                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}}},
                                                                                                                                                                "argument": {"application": {"function": {"variable": "letExpr"}, "argument": {"variable": "b"}}}}},
                                                                                                                                                            "argument": {
                                                                                                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}}},
                                                                                                                                                      {
                                                                                                                                                        "name": "typeScheme",
                                                                                                                                                        "term": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                                                                                                                            "argument": {"variable": "b"}}}}]}}}},
                                                                                                                                            "typeScheme": {
                                                                                                                                              "variables": [],
                                                                                                                                              "body": {"function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                              "constraints": []}}],
                                                                                                                                        "body": {
                                                                                                                                          "let": {
                                                                                                                                            "bindings": [
                                                                                                                                              {
                                                                                                                                                "name": "expandedBindings",
                                                                                                                                                "term": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {
                                                                                                                                                          "typeApplication": {
                                                                                                                                                            "body": {
                                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                                            "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                                        "argument": {"variable": "expandBinding"}}},
                                                                                                                                                    "argument": {"variable": "bindings"}}},
                                                                                                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                                                                                            "body": {
                                                                                                                                              "let": {
                                                                                                                                                "bindings": [
                                                                                                                                                  {
                                                                                                                                                    "name": "substituteBinding",
                                                                                                                                                    "term": {
                                                                                                                                                      "lambda": {
                                                                                                                                                        "parameter": "term",
                                                                                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                        "body": {
                                                                                                                                                          "lambda": {
                                                                                                                                                            "parameter": "b",
                                                                                                                                                            "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                                                                            "body": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {
                                                                                                                                                                      "application": {
                                                                                                                                                                        "function": {"variable": "hydra.core.variables.replaceFreeTermVariable"},
                                                                                                                                                                        "argument": {
                                                                                                                                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}}},
                                                                                                                                                                    "argument": {
                                                                                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}},
                                                                                                                                                                "argument": {"variable": "term"}}}}}}},
                                                                                                                                                    "typeScheme": {
                                                                                                                                                      "variables": [],
                                                                                                                                                      "body": {
                                                                                                                                                        "function": {
                                                                                                                                                          "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                          "codomain": {"function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                                      "constraints": []}}],
                                                                                                                                                "body": {
                                                                                                                                                  "let": {
                                                                                                                                                    "bindings": [
                                                                                                                                                      {
                                                                                                                                                        "name": "substituteAll",
                                                                                                                                                        "term": {
                                                                                                                                                          "lambda": {
                                                                                                                                                            "parameter": "bs",
                                                                                                                                                            "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                                                                                                                                            "body": {
                                                                                                                                                              "lambda": {
                                                                                                                                                                "parameter": "term",
                                                                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                                "body": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {
                                                                                                                                                                      "application": {
                                                                                                                                                                        "function": {
                                                                                                                                                                          "application": {
                                                                                                                                                                            "function": {
                                                                                                                                                                              "typeApplication": {
                                                                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                                "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                                                            "argument": {"variable": "substituteBinding"}}},
                                                                                                                                                                        "argument": {"variable": "term"}}},
                                                                                                                                                                    "argument": {"variable": "bs"}}}}}}},
                                                                                                                                                        "typeScheme": {
                                                                                                                                                          "variables": [],
                                                                                                                                                          "body": {
                                                                                                                                                            "function": {
                                                                                                                                                              "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                                                                                                                                              "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                                                                          "constraints": []}}],
                                                                                                                                                    "body": {
                                                                                                                                                      "let": {
                                                                                                                                                        "bindings": [
                                                                                                                                                          {
                                                                                                                                                            "name": "expandedBody",
                                                                                                                                                            "term": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {"application": {"function": {"variable": "substituteAll"}, "argument": {"variable": "expandedBindings"}}},
                                                                                                                                                                "argument": {"variable": "body"}}},
                                                                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                                                        "body": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                    "body": {
                                                                                                                                                                      "typeApplication": {
                                                                                                                                                                        "body": {
                                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                                                                                "argument": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {"application": {"function": {"variable": "reduce"}, "argument": {"variable": "eager"}}},
                                                                                                                                                                    "argument": {"variable": "expandedBody"}}}}},
                                                                                                                                                            "argument": {
                                                                                                                                                              "lambda": {
                                                                                                                                                                "parameter": "reducedBody",
                                                                                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                                                                                "body": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {
                                                                                                                                                                      "application": {
                                                                                                                                                                        "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                                                                                        "argument": {"variable": "reducedBody"}}},
                                                                                                                                                                    "argument": {"variable": "args"}}}}}}}}}}}}}}}}}}}}}}}}}}]}},
                                                                                                            "argument": {"variable": "stripped"}}}}}}}}}}}}}}}}}}}}},
                                                                    "typeScheme": {
                                                                      "variables": [],
                                                                      "body": {
                                                                        "function": {
                                                                          "domain": {"literal": "boolean"},
                                                                          "codomain": {
                                                                            "function": {
                                                                              "domain": {"variable": "hydra.core.model.Term"},
                                                                              "codomain": {
                                                                                "function": {
                                                                                  "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}}}},
                                                                      "constraints": []}}],
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "mapping",
                                                                        "term": {
                                                                          "lambda": {
                                                                            "parameter": "recurse",
                                                                            "domain": {
                                                                              "function": {
                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                            "body": {
                                                                              "lambda": {
                                                                                "parameter": "mid",
                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "doRecurse"}, "argument": {"variable": "eager"}}},
                                                                                                        "argument": {"variable": "mid"}}}}},
                                                                                                "argument": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "mid"}}}}},
                                                                                            "argument": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {"body": {"either": {"right": {"variable": "mid"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                                "type": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                                    "argument": {
                                                                                      "lambda": {
                                                                                        "parameter": "inner",
                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "applyIfNullary"}, "argument": {"variable": "eager"}}},
                                                                                                "argument": {"variable": "inner"}}},
                                                                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}}}},
                                                                        "typeScheme": {
                                                                          "variables": [],
                                                                          "body": {
                                                                            "function": {
                                                                              "domain": {
                                                                                "function": {
                                                                                  "domain": {"variable": "hydra.core.model.Term"},
                                                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                                              "codomain": {
                                                                                "function": {
                                                                                  "domain": {"variable": "hydra.core.model.Term"},
                                                                                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                          "constraints": []}}],
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.rewriting.rewriteTermM"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                            "argument": {"variable": "mapping"}}},
                                                                        "argument": {"variable": "term"}}}}}}}}}}}}}}}}}}}}}}}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {"literal": {"string": "A term evaluation function which is alternatively lazy or eager"}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.termIsClosed",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"literal": "boolean"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "term",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "application": {
                    "function": {
                      "typeApplication": {"body": {"variable": "hydra.core.lib.sets.isEmpty"}, "type": {"variable": "hydra.core.model.Name"}}},
                    "argument": {
                      "application": {"function": {"variable": "hydra.core.variables.freeVariablesInTerm"}, "argument": {"variable": "term"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Whether a term is closed, i.e. represents a complete program"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.reduction.termIsValue",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"literal": "boolean"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "term",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "forList",
                        "term": {
                          "lambda": {
                            "parameter": "els",
                            "domain": {"list": {"variable": "hydra.core.model.Term"}},
                            "body": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"literal": "boolean"}}},
                                            "type": {"variable": "hydra.core.model.Term"}}},
                                        "argument": {
                                          "lambda": {
                                            "parameter": "b",
                                            "domain": {"literal": "boolean"},
                                            "body": {
                                              "lambda": {
                                                "parameter": "t",
                                                "domain": {"variable": "hydra.core.model.Term"},
                                                "body": {
                                                  "application": {
                                                    "function": {"application": {"function": {"variable": "hydra.core.lib.logic.and"}, "argument": {"variable": "b"}}},
                                                    "argument": {"application": {"function": {"variable": "hydra.core.reduction.termIsValue"}, "argument": {"variable": "t"}}}}}}}}}}},
                                    "argument": {"literal": {"boolean": true}}}},
                                "argument": {"variable": "els"}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {"function": {"domain": {"list": {"variable": "hydra.core.model.Term"}}, "codomain": {"literal": "boolean"}}},
                          "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "checkField",
                            "term": {
                              "lambda": {
                                "parameter": "f",
                                "domain": {"variable": "hydra.core.model.Field"},
                                "body": {
                                  "application": {
                                    "function": {"variable": "hydra.core.reduction.termIsValue"},
                                    "argument": {
                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "term"}}, "argument": {"variable": "f"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {"function": {"domain": {"variable": "hydra.core.model.Field"}, "codomain": {"literal": "boolean"}}},
                              "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "checkFields",
                                "term": {
                                  "lambda": {
                                    "parameter": "fields",
                                    "domain": {"list": {"variable": "hydra.core.model.Field"}},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"literal": "boolean"}}},
                                                    "type": {"variable": "hydra.core.model.Field"}}},
                                                "argument": {
                                                  "lambda": {
                                                    "parameter": "b",
                                                    "domain": {"literal": "boolean"},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "f",
                                                        "domain": {"variable": "hydra.core.model.Field"},
                                                        "body": {
                                                          "application": {
                                                            "function": {"application": {"function": {"variable": "hydra.core.lib.logic.and"}, "argument": {"variable": "b"}}},
                                                            "argument": {"application": {"function": {"variable": "checkField"}, "argument": {"variable": "f"}}}}}}}}}}},
                                            "argument": {"literal": {"boolean": true}}}},
                                        "argument": {"variable": "fields"}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {"function": {"domain": {"list": {"variable": "hydra.core.model.Field"}}, "codomain": {"literal": "boolean"}}},
                                  "constraints": []}}],
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "checkCaseAlternatives",
                                    "term": {
                                      "lambda": {
                                        "parameter": "alts",
                                        "domain": {"list": {"variable": "hydra.core.model.CaseAlternative"}},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"literal": "boolean"}}},
                                                        "type": {"variable": "hydra.core.model.CaseAlternative"}}},
                                                    "argument": {
                                                      "lambda": {
                                                        "parameter": "b",
                                                        "domain": {"literal": "boolean"},
                                                        "body": {
                                                          "lambda": {
                                                            "parameter": "a",
                                                            "domain": {"variable": "hydra.core.model.CaseAlternative"},
                                                            "body": {
                                                              "application": {
                                                                "function": {"application": {"function": {"variable": "hydra.core.lib.logic.and"}, "argument": {"variable": "b"}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"variable": "hydra.core.reduction.termIsValue"},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {"project": {"typeName": "hydra.core.model.CaseAlternative", "fieldName": "handler"}},
                                                                        "argument": {"variable": "a"}}}}}}}}}}}}},
                                                "argument": {"literal": {"boolean": true}}}},
                                            "argument": {"variable": "alts"}}}}},
                                    "typeScheme": {
                                      "variables": [],
                                      "body": {"function": {"domain": {"list": {"variable": "hydra.core.model.CaseAlternative"}}, "codomain": {"literal": "boolean"}}},
                                      "constraints": []}}],
                                "body": {
                                  "application": {
                                    "function": {
                                      "cases": {
                                        "typeName": "hydra.core.model.Term",
                                        "default": {"literal": {"boolean": false}},
                                        "cases": [
                                          {
                                            "name": "application",
                                            "handler": {
                                              "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Application"}, "body": {"literal": {"boolean": false}}}}},
                                          {
                                            "name": "cases",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "cs",
                                                "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"variable": "hydra.core.lib.logic.and"},
                                                        "argument": {
                                                          "application": {
                                                            "function": {"variable": "checkCaseAlternatives"},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "cases"}},
                                                                "argument": {"variable": "cs"}}}}}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                    "type": {"literal": "boolean"}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "default"}},
                                                                    "argument": {"variable": "cs"}}}}},
                                                            "argument": {"literal": {"boolean": true}}}},
                                                        "argument": {"variable": "hydra.core.reduction.termIsValue"}}}}}}}},
                                          {
                                            "name": "either",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "e",
                                                "domain": {"either": {"left": {"variable": "hydra.core.model.Term"}, "right": {"variable": "hydra.core.model.Term"}}},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.either"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                "type": {"literal": "boolean"}}},
                                                            "argument": {
                                                              "lambda": {
                                                                "parameter": "l",
                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                "body": {"application": {"function": {"variable": "hydra.core.reduction.termIsValue"}, "argument": {"variable": "l"}}}}}}},
                                                        "argument": {
                                                          "lambda": {
                                                            "parameter": "r",
                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                            "body": {"application": {"function": {"variable": "hydra.core.reduction.termIsValue"}, "argument": {"variable": "r"}}}}}}},
                                                    "argument": {"variable": "e"}}}}}},
                                          {
                                            "name": "lambda",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "l",
                                                "domain": {"variable": "hydra.core.model.Lambda"},
                                                "body": {
                                                  "application": {
                                                    "function": {"variable": "hydra.core.reduction.termIsValue"},
                                                    "argument": {
                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}}},
                                          {
                                            "name": "literal",
                                            "handler": {
                                              "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Literal"}, "body": {"literal": {"boolean": true}}}}},
                                          {
                                            "name": "project",
                                            "handler": {
                                              "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Projection"}, "body": {"literal": {"boolean": true}}}}},
                                          {
                                            "name": "unwrap",
                                            "handler": {"lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Name"}, "body": {"literal": {"boolean": true}}}}},
                                          {
                                            "name": "list",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "els",
                                                "domain": {"list": {"variable": "hydra.core.model.Term"}},
                                                "body": {"application": {"function": {"variable": "forList"}, "argument": {"variable": "els"}}}}}},
                                          {
                                            "name": "map",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "m",
                                                "domain": {"map": {"keys": {"variable": "hydra.core.model.Term"}, "values": {"variable": "hydra.core.model.Term"}}},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"literal": "boolean"}}},
                                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                                            "argument": {
                                                              "lambda": {
                                                                "parameter": "b",
                                                                "domain": {"literal": "boolean"},
                                                                "body": {
                                                                  "lambda": {
                                                                    "parameter": "kv",
                                                                    "domain": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"variable": "hydra.core.model.Term"}}},
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {"application": {"function": {"variable": "hydra.core.lib.logic.and"}, "argument": {"variable": "b"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {"variable": "hydra.core.lib.logic.and"},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {"variable": "hydra.core.reduction.termIsValue"},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {
                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                                                        "argument": {"variable": "kv"}}}}}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"variable": "hydra.core.reduction.termIsValue"},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                    "argument": {"variable": "kv"}}}}}}}}}}}}}}},
                                                        "argument": {"literal": {"boolean": true}}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.toList"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                        "argument": {"variable": "m"}}}}}}}},
                                          {
                                            "name": "optional",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "m",
                                                "domain": {"optional": {"variable": "hydra.core.model.Term"}},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                "type": {"literal": "boolean"}}},
                                                            "argument": {"variable": "m"}}},
                                                        "argument": {"literal": {"boolean": true}}}},
                                                    "argument": {"variable": "hydra.core.reduction.termIsValue"}}}}}},
                                          {
                                            "name": "record",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "r",
                                                "domain": {"variable": "hydra.core.model.Record"},
                                                "body": {
                                                  "application": {
                                                    "function": {"variable": "checkFields"},
                                                    "argument": {
                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Record", "fieldName": "fields"}}, "argument": {"variable": "r"}}}}}}}},
                                          {
                                            "name": "set",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "s",
                                                "domain": {"set": {"variable": "hydra.core.model.Term"}},
                                                "body": {
                                                  "application": {
                                                    "function": {"variable": "forList"},
                                                    "argument": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.toList"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                        "argument": {"variable": "s"}}}}}}}},
                                          {
                                            "name": "inject",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "i",
                                                "domain": {"variable": "hydra.core.model.Injection"},
                                                "body": {
                                                  "application": {
                                                    "function": {"variable": "checkField"},
                                                    "argument": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.model.Injection", "fieldName": "field"}},
                                                        "argument": {"variable": "i"}}}}}}}},
                                          {"name": "unit", "handler": {"lambda": {"parameter": "_", "domain": "unit", "body": {"literal": {"boolean": true}}}}},
                                          {
                                            "name": "variable",
                                            "handler": {"lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Name"}, "body": {"literal": {"boolean": false}}}}}]}},
                                    "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "term"}}}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Whether a term has been fully reduced to a value"}}}]}}}}}]}