packages feed

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

{
  "name": "hydra.core.variables",
  "metadata": {
    "description": "Free variable analysis, term-level substitution, and unshadowing",
    "comments": [],
    "seeAlso": [],
    "provisions": []},
  "dependencies": [
    {"module": "hydra.core.coders"},
    {"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.pairs"},
    {"module": "hydra.core.lib.sets"},
    {"module": "hydra.core.lib.strings"},
    {"module": "hydra.core.model"},
    {"module": "hydra.core.rewriting"}],
  "definitions": [
    {
      "term": {
        "name": "hydra.core.variables.applicationSpine",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Application"}, "isLazy": false}],
          "result": {
            "type": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "app",
                "domain": {"variable": "hydra.core.model.Application"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "fn",
                        "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": "arg",
                            "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": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {
                                        "body": {"pair": {"first": {"variable": "fn"}, "second": {"list": [{"variable": "arg"}]}}},
                                        "type": {"variable": "hydra.core.model.Term"}}},
                                    "type": {"list": {"variable": "hydra.core.model.Term"}}}},
                                "cases": [
                                  {
                                    "name": "application",
                                    "handler": {
                                      "lambda": {
                                        "parameter": "innerApp",
                                        "domain": {"variable": "hydra.core.model.Application"},
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "inner",
                                                "term": {
                                                  "application": {"function": {"variable": "hydra.core.variables.applicationSpine"}, "argument": {"variable": "innerApp"}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "pair": {
                                                        "first": {
                                                          "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": "inner"}}},
                                                        "second": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat2"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                "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": "inner"}}}}},
                                                            "argument": {"list": [{"variable": "arg"}]}}}}},
                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                "type": {"list": {"variable": "hydra.core.model.Term"}}}}}}}}}]}},
                            "argument": {"variable": "fn"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {"string": "Peel an Application chain into its ultimate function head and the ordered list of arguments applied to it"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.eagerFreeVariablesInTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "term",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "dfltVars",
                        "term": {
                          "typeLambda": {
                            "parameter": "t0",
                            "body": {
                              "lambda": {
                                "parameter": "_",
                                "domain": {"variable": "t0"},
                                "body": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                "type": {"variable": "hydra.core.model.Term"}}},
                                            "argument": {
                                              "lambda": {
                                                "parameter": "s",
                                                "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "t",
                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                    "body": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                            "argument": {"variable": "s"}}},
                                                        "argument": {
                                                          "application": {"function": {"variable": "hydra.core.variables.eagerFreeVariablesInTerm"}, "argument": {"variable": "t"}}}}}}}}}}},
                                        "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                    "argument": {"application": {"function": {"variable": "hydra.core.rewriting.subterms"}, "argument": {"variable": "term"}}}}}}}}},
                        "typeScheme": {
                          "variables": ["t0"],
                          "body": {"function": {"domain": {"variable": "t0"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}},
                          "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "cases": {
                            "typeName": "hydra.core.model.Term",
                            "default": {
                              "application": {"function": {"typeApplication": {"body": {"variable": "dfltVars"}, "type": "unit"}}, "argument": "unit"}},
                            "cases": [
                              {
                                "name": "lambda",
                                "handler": {
                                  "lambda": {
                                    "parameter": "_l",
                                    "domain": {"variable": "hydra.core.model.Lambda"},
                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}}},
                              {
                                "name": "application",
                                "handler": {
                                  "lambda": {
                                    "parameter": "app",
                                    "domain": {"variable": "hydra.core.model.Application"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "lambda": {
                                            "parameter": "app",
                                            "domain": {"variable": "hydra.core.model.Application"},
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "spined",
                                                    "term": {"application": {"function": {"variable": "hydra.core.variables.applicationSpine"}, "argument": {"variable": "app"}}},
                                                    "typeScheme": {
                                                      "variables": [],
                                                      "body": {"pair": {"first": {"variable": "hydra.core.model.Term"}, "second": {"list": {"variable": "hydra.core.model.Term"}}}},
                                                      "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "headTerm",
                                                        "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": "spined"}}},
                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "args",
                                                            "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": "spined"}}},
                                                            "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Term"}}, "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "argsVars",
                                                                "term": {
                                                                  "application": {
                                                                    "function": {
                                                                      "lambda": {
                                                                        "parameter": "argList",
                                                                        "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": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                    "argument": {
                                                                                      "lambda": {
                                                                                        "parameter": "s",
                                                                                        "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                                                                        "body": {
                                                                                          "lambda": {
                                                                                            "parameter": "a",
                                                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "argument": {"variable": "s"}}},
                                                                                                "argument": {
                                                                                                  "application": {"function": {"variable": "hydra.core.variables.eagerFreeVariablesInTerm"}, "argument": {"variable": "a"}}}}}}}}}}},
                                                                                "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                                            "argument": {"variable": "argList"}}}}},
                                                                    "argument": {"variable": "args"}}},
                                                                "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "cases": {
                                                                    "typeName": "hydra.core.model.Term",
                                                                    "default": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "argument": {
                                                                              "application": {"function": {"variable": "hydra.core.variables.eagerFreeVariablesInTerm"}, "argument": {"variable": "headTerm"}}}}},
                                                                        "argument": {"variable": "argsVars"}}},
                                                                    "cases": [
                                                                      {
                                                                        "name": "lambda",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "_",
                                                                            "domain": {"variable": "hydra.core.model.Lambda"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {"variable": "hydra.core.variables.eagerVarsOfRedexBody"},
                                                                                                "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                                                            "argument": {"variable": "headTerm"}}},
                                                                                        "argument": {"variable": "args"}}}}},
                                                                                "argument": {"variable": "argsVars"}}}}}}]}},
                                                                "argument": {"variable": "headTerm"}}}}}}}}}}}}},
                                        "argument": {"variable": "app"}}}}}},
                              {
                                "name": "let",
                                "handler": {
                                  "lambda": {
                                    "parameter": "l",
                                    "domain": {"variable": "hydra.core.model.Let"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.sets.difference"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {"function": {"typeApplication": {"body": {"variable": "dfltVars"}, "type": "unit"}}, "argument": "unit"}}}},
                                        "argument": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "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.Name"}}},
                                                    "argument": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}}},
                                                "argument": {
                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "l"}}}}}}}}}}}},
                              {
                                "name": "variable",
                                "handler": {
                                  "lambda": {
                                    "parameter": "v",
                                    "domain": {"variable": "hydra.core.model.Name"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.sets.singleton"}, "type": {"variable": "hydra.core.model.Name"}}},
                                        "argument": {"variable": "v"}}}}}}]}},
                        "argument": {"variable": "term"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Find the free variables of a term that are referenced eagerly, i.e. outside of any nested lambda body; used to break false dependency cycles caused by DSL-level thunks such as hydra.core.parsers.lazy"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.eagerVarsOfRedexBody",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"set": {"variable": "hydra.core.model.Name"}}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false},
            {"name": "arg2", "type": {"list": {"variable": "hydra.core.model.Term"}}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "boundSoFar",
                "domain": {"set": {"variable": "hydra.core.model.Name"}},
                "body": {
                  "lambda": {
                    "parameter": "body",
                    "domain": {"variable": "hydra.core.model.Term"},
                    "body": {
                      "lambda": {
                        "parameter": "remainingArgs",
                        "domain": {"list": {"variable": "hydra.core.model.Term"}},
                        "body": {
                          "application": {
                            "function": {
                              "cases": {
                                "typeName": "hydra.core.model.Term",
                                "default": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.sets.difference"}, "type": {"variable": "hydra.core.model.Name"}}},
                                        "argument": {
                                          "application": {"function": {"variable": "hydra.core.variables.eagerFreeVariablesInTerm"}, "argument": {"variable": "body"}}}}},
                                    "argument": {"variable": "boundSoFar"}}},
                                "cases": [
                                  {
                                    "name": "lambda",
                                    "handler": {
                                      "lambda": {
                                        "parameter": "lam",
                                        "domain": {"variable": "hydra.core.model.Lambda"},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.isEmpty"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                        "argument": {"variable": "remainingArgs"}}}}},
                                                "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                            "argument": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "param",
                                                    "term": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
                                                        "argument": {"variable": "lam"}}},
                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"variable": "hydra.core.variables.eagerVarsOfRedexBody"},
                                                            "argument": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                    "argument": {"variable": "param"}}},
                                                                "argument": {"variable": "boundSoFar"}}}}},
                                                        "argument": {
                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "lam"}}}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.drop"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                            "argument": {"literal": {"integer": {"int32": 1}}}}},
                                                        "argument": {"variable": "remainingArgs"}}}}}}}}}}}}]}},
                            "argument": {"variable": "body"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Find the eager free variables of a curried beta-redex's body, descending through each immediately-applied lambda layer"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.freeTypeVariablesInTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "term0",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "allOf",
                        "term": {
                          "typeLambda": {
                            "parameter": "t0",
                            "body": {
                              "lambda": {
                                "parameter": "sets",
                                "domain": {"list": {"set": {"variable": "t0"}}},
                                "body": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"set": {"variable": "t0"}}}},
                                                "type": {"set": {"variable": "t0"}}}},
                                            "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "t0"}}}}},
                                        "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "t0"}}}}},
                                    "argument": {"variable": "sets"}}}}}}},
                        "typeScheme": {
                          "variables": ["t0"],
                          "body": {"function": {"domain": {"list": {"set": {"variable": "t0"}}}, "codomain": {"set": {"variable": "t0"}}}},
                          "constraints": [{"key": "t0", "value": {"classes": [{"simple": "ordering"}]}}]}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "tryType",
                            "term": {
                              "lambda": {
                                "parameter": "tvars",
                                "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                "body": {
                                  "lambda": {
                                    "parameter": "typ",
                                    "domain": {"variable": "hydra.core.model.Type"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.sets.difference"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {"application": {"function": {"variable": "hydra.core.variables.freeVariablesInType"}, "argument": {"variable": "typ"}}}}},
                                        "argument": {"variable": "tvars"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {
                                  "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                  "codomain": {
                                    "function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                              "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "getAll",
                                "term": {
                                  "lambda": {
                                    "parameter": "vars",
                                    "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                    "body": {
                                      "lambda": {
                                        "parameter": "term",
                                        "domain": {"variable": "hydra.core.model.Term"},
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "recurse",
                                                "term": {"application": {"function": {"variable": "getAll"}, "argument": {"variable": "vars"}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {
                                                    "function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "dflt",
                                                    "term": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "allOf"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                    "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                "argument": {"variable": "recurse"}}},
                                                            "argument": {"application": {"function": {"variable": "hydra.core.rewriting.subterms"}, "argument": {"variable": "term"}}}}}}},
                                                    "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "cases": {
                                                        "typeName": "hydra.core.model.Term",
                                                        "default": {"variable": "dflt"},
                                                        "cases": [
                                                          {
                                                            "name": "lambda",
                                                            "handler": {
                                                              "lambda": {
                                                                "parameter": "l",
                                                                "domain": {"variable": "hydra.core.model.Lambda"},
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "domt",
                                                                        "term": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                        "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                    "argument": {
                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "domain"}}, "argument": {"variable": "l"}}}}},
                                                                                "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                                            "argument": {"application": {"function": {"variable": "tryType"}, "argument": {"variable": "vars"}}}}},
                                                                        "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "argument": {"variable": "domt"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"variable": "recurse"},
                                                                            "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": "forBinding",
                                                                        "term": {
                                                                          "lambda": {
                                                                            "parameter": "b",
                                                                            "domain": {"variable": "hydra.core.model.Binding"},
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "newVars",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                    "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                                                                    "argument": {"variable": "b"}}}}},
                                                                                            "argument": {"variable": "vars"}}},
                                                                                        "argument": {
                                                                                          "lambda": {
                                                                                            "parameter": "ts",
                                                                                            "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "argument": {"variable": "vars"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
                                                                                                        "argument": {"variable": "ts"}}}}}}}}}}},
                                                                                    "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {"application": {"function": {"variable": "getAll"}, "argument": {"variable": "newVars"}}},
                                                                                            "argument": {
                                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                    "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                                                                    "argument": {"variable": "b"}}}}},
                                                                                            "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                                                        "argument": {
                                                                                          "lambda": {
                                                                                            "parameter": "ts",
                                                                                            "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "tryType"}, "argument": {"variable": "newVars"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                                                                                    "argument": {"variable": "ts"}}}}}}}}}}}}}}},
                                                                        "typeScheme": {
                                                                          "variables": [],
                                                                          "body": {
                                                                            "function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                          "constraints": []}}],
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"typeApplication": {"body": {"variable": "allOf"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                            "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                        "argument": {"variable": "forBinding"}}},
                                                                                    "argument": {
                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "l"}}}}}}}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"variable": "recurse"},
                                                                            "argument": {
                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}}}}}}},
                                                          {
                                                            "name": "typeApplication",
                                                            "handler": {
                                                              "lambda": {
                                                                "parameter": "tt",
                                                                "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"application": {"function": {"variable": "tryType"}, "argument": {"variable": "vars"}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
                                                                                "argument": {"variable": "tt"}}}}}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {"variable": "recurse"},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                            "argument": {"variable": "tt"}}}}}}}}}},
                                                          {
                                                            "name": "typeLambda",
                                                            "handler": {
                                                              "lambda": {
                                                                "parameter": "tl",
                                                                "domain": {"variable": "hydra.core.model.TypeLambda"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"application": {"function": {"variable": "tryType"}, "argument": {"variable": "vars"}}},
                                                                            "argument": {
                                                                              "inject": {
                                                                                "typeName": "hydra.core.model.Type",
                                                                                "field": {
                                                                                  "name": "variable",
                                                                                  "term": {
                                                                                    "application": {
                                                                                      "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "parameter"}},
                                                                                      "argument": {"variable": "tl"}}}}}}}}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {"variable": "recurse"},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "body"}},
                                                                            "argument": {"variable": "tl"}}}}}}}}}}]}},
                                                    "argument": {"variable": "term"}}}}}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {
                                    "function": {
                                      "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                      "codomain": {
                                        "function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                  "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {"variable": "getAll"},
                                    "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                "argument": {"variable": "term0"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Get the set of free type variables in a term (including schema names, where they appear in type annotations). In this context, only the type schemes of let bindings can bind type variables; type lambdas do not."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.freeVariablesInTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "term",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "dfltVars",
                        "term": {
                          "typeLambda": {
                            "parameter": "t0",
                            "body": {
                              "lambda": {
                                "parameter": "_",
                                "domain": {"variable": "t0"},
                                "body": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                "type": {"variable": "hydra.core.model.Term"}}},
                                            "argument": {
                                              "lambda": {
                                                "parameter": "s",
                                                "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "t",
                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                    "body": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                            "argument": {"variable": "s"}}},
                                                        "argument": {"application": {"function": {"variable": "hydra.core.variables.freeVariablesInTerm"}, "argument": {"variable": "t"}}}}}}}}}}},
                                        "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                    "argument": {"application": {"function": {"variable": "hydra.core.rewriting.subterms"}, "argument": {"variable": "term"}}}}}}}}},
                        "typeScheme": {
                          "variables": ["t0"],
                          "body": {"function": {"domain": {"variable": "t0"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}},
                          "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "cases": {
                            "typeName": "hydra.core.model.Term",
                            "default": {
                              "application": {"function": {"typeApplication": {"body": {"variable": "dfltVars"}, "type": "unit"}}, "argument": "unit"}},
                            "cases": [
                              {
                                "name": "lambda",
                                "handler": {
                                  "lambda": {
                                    "parameter": "l",
                                    "domain": {"variable": "hydra.core.model.Lambda"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.delete"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {
                                                "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
                                                "argument": {"variable": "l"}}}}},
                                        "argument": {
                                          "application": {
                                            "function": {"variable": "hydra.core.variables.freeVariablesInTerm"},
                                            "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": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.sets.difference"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {"function": {"typeApplication": {"body": {"variable": "dfltVars"}, "type": "unit"}}, "argument": "unit"}}}},
                                        "argument": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "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.Name"}}},
                                                    "argument": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}}},
                                                "argument": {
                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "l"}}}}}}}}}}}},
                              {
                                "name": "variable",
                                "handler": {
                                  "lambda": {
                                    "parameter": "v",
                                    "domain": {"variable": "hydra.core.model.Name"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.sets.singleton"}, "type": {"variable": "hydra.core.model.Name"}}},
                                        "argument": {"variable": "v"}}}}}}]}},
                        "argument": {"variable": "term"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Find the free variables (i.e. variables not bound by a lambda or let) in a term"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.freeVariablesInType",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "typ",
                "domain": {"variable": "hydra.core.model.Type"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "dfltVars",
                        "term": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "typeApplication": {
                                        "body": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                        "type": {"variable": "hydra.core.model.Type"}}},
                                    "argument": {
                                      "lambda": {
                                        "parameter": "s",
                                        "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                        "body": {
                                          "lambda": {
                                            "parameter": "t",
                                            "domain": {"variable": "hydra.core.model.Type"},
                                            "body": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                    "argument": {"variable": "s"}}},
                                                "argument": {"application": {"function": {"variable": "hydra.core.variables.freeVariablesInType"}, "argument": {"variable": "t"}}}}}}}}}}},
                                "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                            "argument": {"application": {"function": {"variable": "hydra.core.rewriting.subtypes"}, "argument": {"variable": "typ"}}}}},
                        "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "cases": {
                            "typeName": "hydra.core.model.Type",
                            "default": {"variable": "dfltVars"},
                            "cases": [
                              {
                                "name": "forall",
                                "handler": {
                                  "lambda": {
                                    "parameter": "lt",
                                    "domain": {"variable": "hydra.core.model.ForallType"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.delete"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {
                                                "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
                                                "argument": {"variable": "lt"}}}}},
                                        "argument": {
                                          "application": {
                                            "function": {"variable": "hydra.core.variables.freeVariablesInType"},
                                            "argument": {
                                              "application": {
                                                "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "body"}},
                                                "argument": {"variable": "lt"}}}}}}}}}},
                              {
                                "name": "variable",
                                "handler": {
                                  "lambda": {
                                    "parameter": "v",
                                    "domain": {"variable": "hydra.core.model.Name"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.sets.singleton"}, "type": {"variable": "hydra.core.model.Name"}}},
                                        "argument": {"variable": "v"}}}}}}]}},
                        "argument": {"variable": "typ"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Find the free variables (i.e. variables not bound by a lambda or let) in a type"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.freeVariablesInTypeOrdered",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"list": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "typ",
                "domain": {"variable": "hydra.core.model.Type"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "collectVars",
                        "term": {
                          "lambda": {
                            "parameter": "boundVars",
                            "domain": {"set": {"variable": "hydra.core.model.Name"}},
                            "body": {
                              "lambda": {
                                "parameter": "t",
                                "domain": {"variable": "hydra.core.model.Type"},
                                "body": {
                                  "application": {
                                    "function": {
                                      "cases": {
                                        "typeName": "hydra.core.model.Type",
                                        "default": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                        "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                    "argument": {"application": {"function": {"variable": "collectVars"}, "argument": {"variable": "boundVars"}}}}},
                                                "argument": {"application": {"function": {"variable": "hydra.core.rewriting.subtypes"}, "argument": {"variable": "t"}}}}}}},
                                        "cases": [
                                          {
                                            "name": "variable",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "v",
                                                "domain": {"variable": "hydra.core.model.Name"},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                    "argument": {"variable": "v"}}},
                                                                "argument": {"variable": "boundVars"}}}}},
                                                        "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                    "argument": {"list": [{"variable": "v"}]}}}}}},
                                          {
                                            "name": "forall",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "ft",
                                                "domain": {"variable": "hydra.core.model.ForallType"},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"variable": "collectVars"},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
                                                                    "argument": {"variable": "ft"}}}}},
                                                            "argument": {"variable": "boundVars"}}}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "body"}},
                                                        "argument": {"variable": "ft"}}}}}}}}]}},
                                    "argument": {"variable": "t"}}}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {
                            "function": {
                              "domain": {"set": {"variable": "hydra.core.model.Name"}},
                              "codomain": {
                                "function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                          "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.distinct"}, "type": {"variable": "hydra.core.model.Name"}}},
                        "argument": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {"variable": "collectVars"},
                                "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                            "argument": {"variable": "typ"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Find the free variables in a type in deterministic left-to-right order"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.freeVariablesInTypeScheme",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.TypeScheme"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "ts",
                "domain": {"variable": "hydra.core.model.TypeScheme"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "vars",
                        "term": {
                          "application": {
                            "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
                            "argument": {"variable": "ts"}}},
                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "t",
                            "term": {
                              "application": {
                                "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                "argument": {"variable": "ts"}}},
                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {"body": {"variable": "hydra.core.lib.sets.difference"}, "type": {"variable": "hydra.core.model.Name"}}},
                                "argument": {"application": {"function": {"variable": "hydra.core.variables.freeVariablesInType"}, "argument": {"variable": "t"}}}}},
                            "argument": {
                              "application": {
                                "function": {
                                  "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                "argument": {"variable": "vars"}}}}}}}}}}},
            "annotation": {
              "map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Find free variables in a type scheme"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.freeVariablesInTypeSchemeSimple",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.TypeScheme"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "ts",
                "domain": {"variable": "hydra.core.model.TypeScheme"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "vars",
                        "term": {
                          "application": {
                            "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
                            "argument": {"variable": "ts"}}},
                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "t",
                            "term": {
                              "application": {
                                "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                "argument": {"variable": "ts"}}},
                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {"body": {"variable": "hydra.core.lib.sets.difference"}, "type": {"variable": "hydra.core.model.Name"}}},
                                "argument": {
                                  "application": {"function": {"variable": "hydra.core.variables.freeVariablesInTypeSimple"}, "argument": {"variable": "t"}}}}},
                            "argument": {
                              "application": {
                                "function": {
                                  "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                "argument": {"variable": "vars"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Find free variables in a type scheme (simple version)"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.freeVariablesInTypeSimple",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "typ",
                "domain": {"variable": "hydra.core.model.Type"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "helper",
                        "term": {
                          "lambda": {
                            "parameter": "types",
                            "domain": {"set": {"variable": "hydra.core.model.Name"}},
                            "body": {
                              "lambda": {
                                "parameter": "typ",
                                "domain": {"variable": "hydra.core.model.Type"},
                                "body": {
                                  "application": {
                                    "function": {
                                      "cases": {
                                        "typeName": "hydra.core.model.Type",
                                        "default": {"variable": "types"},
                                        "cases": [
                                          {
                                            "name": "variable",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "v",
                                                "domain": {"variable": "hydra.core.model.Name"},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "argument": {"variable": "v"}}},
                                                    "argument": {"variable": "types"}}}}}}]}},
                                    "argument": {"variable": "typ"}}}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {
                            "function": {
                              "domain": {"set": {"variable": "hydra.core.model.Name"}},
                              "codomain": {
                                "function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                          "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "typeApplication": {"body": {"variable": "hydra.core.rewriting.foldOverType"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                    "argument": {"inject": {"typeName": "hydra.core.coders.TraversalOrder", "field": {"name": "pre", "term": "unit"}}}}},
                                "argument": {"variable": "helper"}}},
                            "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                        "argument": {"variable": "typ"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Same as freeVariablesInType, but ignores the binding action of lambda types"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.freshNameAvoiding",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {"name": "arg1", "type": {"set": {"variable": "hydra.core.model.Name"}}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Name"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "base",
                "domain": {"variable": "hydra.core.model.Name"},
                "body": {
                  "lambda": {
                    "parameter": "avoid",
                    "domain": {"set": {"variable": "hydra.core.model.Name"}},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "go",
                            "term": {
                              "lambda": {
                                "parameter": "i",
                                "domain": {"literal": {"integer": "int32"}},
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "candidate",
                                        "term": {
                                          "wrap": {
                                            "typeName": "hydra.core.model.Name",
                                            "body": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "base"}}}}},
                                                "argument": {"application": {"function": {"variable": "hydra.core.lib.literals.printInt32"}, "argument": {"variable": "i"}}}}}}},
                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "argument": {"variable": "candidate"}}},
                                                    "argument": {"variable": "avoid"}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {"variable": "go"},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.add"}, "type": {"literal": {"integer": "int32"}}}},
                                                        "argument": {"variable": "i"}}},
                                                    "argument": {"literal": {"integer": {"int32": 1}}}}}}}}},
                                        "argument": {"variable": "candidate"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {"function": {"domain": {"literal": {"integer": "int32"}}, "codomain": {"variable": "hydra.core.model.Name"}}},
                              "constraints": []}}],
                        "body": {"application": {"function": {"variable": "go"}, "argument": {"literal": {"integer": {"int32": 2}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {"string": "Find a fresh name based on the given base name, not in the given avoid-set, trying base2, base3, etc."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.isFreeVariableInTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"literal": "boolean"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "v",
                "domain": {"variable": "hydra.core.model.Name"},
                "body": {
                  "lambda": {
                    "parameter": "term",
                    "domain": {"variable": "hydra.core.model.Term"},
                    "body": {
                      "application": {
                        "function": {"variable": "hydra.core.lib.logic.not"},
                        "argument": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                "argument": {"variable": "v"}}},
                            "argument": {
                              "application": {"function": {"variable": "hydra.core.variables.freeVariablesInTerm"}, "argument": {"variable": "term"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Check whether a variable is free (not bound) in a term"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.normalizeTypeVariablesInTerm",
        "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": "replaceName",
                        "term": {
                          "typeLambda": {
                            "parameter": "t0",
                            "body": {
                              "lambda": {
                                "parameter": "subst",
                                "domain": {"map": {"keys": {"variable": "t0"}, "values": {"variable": "t0"}}},
                                "body": {
                                  "lambda": {
                                    "parameter": "v",
                                    "domain": {"variable": "t0"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.withDefault"}, "type": {"variable": "t0"}}},
                                            "argument": {"variable": "v"}}},
                                        "argument": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "t0"}}},
                                                    "type": {"variable": "t0"}}},
                                                "argument": {"variable": "v"}}},
                                            "argument": {"variable": "subst"}}}}}}}}}}},
                        "typeScheme": {
                          "variables": ["t0"],
                          "body": {
                            "function": {
                              "domain": {"map": {"keys": {"variable": "t0"}, "values": {"variable": "t0"}}},
                              "codomain": {"function": {"domain": {"variable": "t0"}, "codomain": {"variable": "t0"}}}}},
                          "constraints": [{"key": "t0", "value": {"classes": [{"simple": "ordering"}]}}]}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "substType",
                            "term": {
                              "lambda": {
                                "parameter": "subst",
                                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                "body": {
                                  "lambda": {
                                    "parameter": "typ",
                                    "domain": {"variable": "hydra.core.model.Type"},
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "rewrite",
                                            "term": {
                                              "lambda": {
                                                "parameter": "recurse",
                                                "domain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "typ",
                                                    "domain": {"variable": "hydra.core.model.Type"},
                                                    "body": {
                                                      "application": {
                                                        "function": {
                                                          "cases": {
                                                            "typeName": "hydra.core.model.Type",
                                                            "default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "typ"}}},
                                                            "cases": [
                                                              {
                                                                "name": "variable",
                                                                "handler": {
                                                                  "lambda": {
                                                                    "parameter": "v",
                                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                                    "body": {
                                                                      "inject": {
                                                                        "typeName": "hydra.core.model.Type",
                                                                        "field": {
                                                                          "name": "variable",
                                                                          "term": {
                                                                            "application": {
                                                                              "function": {
                                                                                "application": {
                                                                                  "function": {"typeApplication": {"body": {"variable": "replaceName"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                  "argument": {"variable": "subst"}}},
                                                                              "argument": {"variable": "v"}}}}}}}}}]}},
                                                        "argument": {"variable": "typ"}}}}}}},
                                            "typeScheme": {
                                              "variables": [],
                                              "body": {
                                                "function": {
                                                  "domain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
                                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}}}},
                                              "constraints": []}}],
                                        "body": {
                                          "application": {
                                            "function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteType"}, "argument": {"variable": "rewrite"}}},
                                            "argument": {"variable": "typ"}}}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {
                                  "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}}}},
                              "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "rewriteWithSubst",
                                "term": {
                                  "lambda": {
                                    "parameter": "state",
                                    "domain": {
                                      "pair": {
                                        "first": {
                                          "pair": {
                                            "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                            "second": {"set": {"variable": "hydra.core.model.Name"}}}},
                                        "second": {"literal": {"integer": "int32"}}}},
                                    "body": {
                                      "lambda": {
                                        "parameter": "term0",
                                        "domain": {"variable": "hydra.core.model.Term"},
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "sb",
                                                "term": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {
                                                            "body": {"variable": "hydra.core.lib.pairs.first"},
                                                            "type": {
                                                              "pair": {
                                                                "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                        "type": {"literal": {"integer": "int32"}}}},
                                                    "argument": {"variable": "state"}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {
                                                    "pair": {
                                                      "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                      "second": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "next",
                                                    "term": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {
                                                                "body": {"variable": "hydra.core.lib.pairs.second"},
                                                                "type": {
                                                                  "pair": {
                                                                    "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                    "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                            "type": {"literal": {"integer": "int32"}}}},
                                                        "argument": {"variable": "state"}}},
                                                    "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "subst",
                                                        "term": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {
                                                                    "body": {"variable": "hydra.core.lib.pairs.first"},
                                                                    "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                            "argument": {"variable": "sb"}}},
                                                        "typeScheme": {
                                                          "variables": [],
                                                          "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                          "constraints": []}}],
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "boundVars",
                                                            "term": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {
                                                                        "body": {"variable": "hydra.core.lib.pairs.second"},
                                                                        "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                    "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                "argument": {"variable": "sb"}}},
                                                            "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "rewrite",
                                                                "term": {
                                                                  "lambda": {
                                                                    "parameter": "recurse",
                                                                    "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                                                    "body": {
                                                                      "lambda": {
                                                                        "parameter": "term",
                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {
                                                                              "cases": {
                                                                                "typeName": "hydra.core.model.Term",
                                                                                "default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}},
                                                                                "cases": [
                                                                                  {
                                                                                    "name": "lambda",
                                                                                    "handler": {
                                                                                      "lambda": {
                                                                                        "parameter": "l",
                                                                                        "domain": {"variable": "hydra.core.model.Lambda"},
                                                                                        "body": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "domain",
                                                                                                "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": {
                                                                                              "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": "l"}}}},
                                                                                                        {
                                                                                                          "name": "domain",
                                                                                                          "term": {
                                                                                                            "application": {
                                                                                                              "function": {
                                                                                                                "application": {
                                                                                                                  "function": {
                                                                                                                    "typeApplication": {
                                                                                                                      "body": {
                                                                                                                        "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                      "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                                  "argument": {"application": {"function": {"variable": "substType"}, "argument": {"variable": "subst"}}}}},
                                                                                                              "argument": {"variable": "domain"}}}},
                                                                                                        {
                                                                                                          "name": "body",
                                                                                                          "term": {
                                                                                                            "application": {
                                                                                                              "function": {
                                                                                                                "application": {
                                                                                                                  "function": {"variable": "rewriteWithSubst"},
                                                                                                                  "argument": {
                                                                                                                    "typeApplication": {
                                                                                                                      "body": {
                                                                                                                        "typeApplication": {
                                                                                                                          "body": {
                                                                                                                            "pair": {
                                                                                                                              "first": {
                                                                                                                                "typeApplication": {
                                                                                                                                  "body": {
                                                                                                                                    "typeApplication": {
                                                                                                                                      "body": {"pair": {"first": {"variable": "subst"}, "second": {"variable": "boundVars"}}},
                                                                                                                                      "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                                                                                  "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                                                              "second": {"variable": "next"}}},
                                                                                                                          "type": {
                                                                                                                            "pair": {
                                                                                                                              "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                                                              "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                                                                                      "type": {"literal": {"integer": "int32"}}}}}},
                                                                                                              "argument": {
                                                                                                                "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}]}}}}}}}}}},
                                                                                  {
                                                                                    "name": "let",
                                                                                    "handler": {
                                                                                      "lambda": {
                                                                                        "parameter": "lt",
                                                                                        "domain": {"variable": "hydra.core.model.Let"},
                                                                                        "body": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "bindings0",
                                                                                                "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": "body0",
                                                                                                    "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": "step",
                                                                                                        "term": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "acc",
                                                                                                            "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                                                                                            "body": {
                                                                                                              "lambda": {
                                                                                                                "parameter": "bs",
                                                                                                                "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                                                                                                "body": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {"variable": "hydra.core.lib.optionals.match"},
                                                                                                                                    "type": {
                                                                                                                                      "pair": {"first": {"variable": "hydra.core.model.Binding"}, "second": {"list": {"variable": "hydra.core.model.Binding"}}}}}},
                                                                                                                                "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.uncons"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                "argument": {"variable": "bs"}}}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.reverse"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                            "argument": {"variable": "acc"}}}}},
                                                                                                                    "argument": {
                                                                                                                      "lambda": {
                                                                                                                        "parameter": "uc",
                                                                                                                        "domain": {
                                                                                                                          "pair": {"first": {"variable": "hydra.core.model.Binding"}, "second": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                                                                        "body": {
                                                                                                                          "let": {
                                                                                                                            "bindings": [
                                                                                                                              {
                                                                                                                                "name": "b",
                                                                                                                                "term": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                        "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                                                                                    "argument": {"variable": "uc"}}},
                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Binding"}, "constraints": []}}],
                                                                                                                            "body": {
                                                                                                                              "let": {
                                                                                                                                "bindings": [
                                                                                                                                  {
                                                                                                                                    "name": "tl",
                                                                                                                                    "term": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                            "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                                                                                        "argument": {"variable": "uc"}}},
                                                                                                                                    "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                                                                                "body": {
                                                                                                                                  "let": {
                                                                                                                                    "bindings": [
                                                                                                                                      {
                                                                                                                                        "name": "noType",
                                                                                                                                        "term": {
                                                                                                                                          "let": {
                                                                                                                                            "bindings": [
                                                                                                                                              {
                                                                                                                                                "name": "newVal",
                                                                                                                                                "term": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {"variable": "rewriteWithSubst"},
                                                                                                                                                        "argument": {
                                                                                                                                                          "typeApplication": {
                                                                                                                                                            "body": {
                                                                                                                                                              "typeApplication": {
                                                                                                                                                                "body": {
                                                                                                                                                                  "pair": {
                                                                                                                                                                    "first": {
                                                                                                                                                                      "typeApplication": {
                                                                                                                                                                        "body": {
                                                                                                                                                                          "typeApplication": {
                                                                                                                                                                            "body": {"pair": {"first": {"variable": "subst"}, "second": {"variable": "boundVars"}}},
                                                                                                                                                                            "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                                                                                                                        "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                                                                                                    "second": {"variable": "next"}}},
                                                                                                                                                                "type": {
                                                                                                                                                                  "pair": {
                                                                                                                                                                    "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                    "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                                                                                                                            "type": {"literal": {"integer": "int32"}}}}}},
                                                                                                                                                    "argument": {
                                                                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}},
                                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                                            "body": {
                                                                                                                                              "let": {
                                                                                                                                                "bindings": [
                                                                                                                                                  {
                                                                                                                                                    "name": "b1",
                                                                                                                                                    "term": {
                                                                                                                                                      "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": {"variable": "newVal"}},
                                                                                                                                                          {
                                                                                                                                                            "name": "typeScheme",
                                                                                                                                                            "term": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.TypeScheme"}}}}]}},
                                                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Binding"}, "constraints": []}}],
                                                                                                                                                "body": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {"variable": "step"},
                                                                                                                                                        "argument": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {
                                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                                                "argument": {"variable": "b1"}}},
                                                                                                                                                            "argument": {"variable": "acc"}}}}},
                                                                                                                                                    "argument": {"variable": "tl"}}}}}}},
                                                                                                                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                                                                                    "body": {
                                                                                                                                      "let": {
                                                                                                                                        "bindings": [
                                                                                                                                          {
                                                                                                                                            "name": "withType",
                                                                                                                                            "term": {
                                                                                                                                              "lambda": {
                                                                                                                                                "parameter": "ts",
                                                                                                                                                "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                                                                                                "body": {
                                                                                                                                                  "let": {
                                                                                                                                                    "bindings": [
                                                                                                                                                      {
                                                                                                                                                        "name": "vars",
                                                                                                                                                        "term": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
                                                                                                                                                            "argument": {"variable": "ts"}}},
                                                                                                                                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                                                                                                                    "body": {
                                                                                                                                                      "let": {
                                                                                                                                                        "bindings": [
                                                                                                                                                          {
                                                                                                                                                            "name": "typ",
                                                                                                                                                            "term": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                                                                                                                                                "argument": {"variable": "ts"}}},
                                                                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                                                                                                                                                        "body": {
                                                                                                                                                          "let": {
                                                                                                                                                            "bindings": [
                                                                                                                                                              {
                                                                                                                                                                "name": "k",
                                                                                                                                                                "term": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {
                                                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                    "argument": {"variable": "vars"}}},
                                                                                                                                                                "typeScheme": {"variables": [], "body": {"literal": {"integer": "int32"}}, "constraints": []}}],
                                                                                                                                                            "body": {
                                                                                                                                                              "let": {
                                                                                                                                                                "bindings": [
                                                                                                                                                                  {
                                                                                                                                                                    "name": "gen",
                                                                                                                                                                    "term": {
                                                                                                                                                                      "lambda": {
                                                                                                                                                                        "parameter": "i",
                                                                                                                                                                        "domain": {"literal": {"integer": "int32"}},
                                                                                                                                                                        "body": {
                                                                                                                                                                          "lambda": {
                                                                                                                                                                            "parameter": "rem",
                                                                                                                                                                            "domain": {"literal": {"integer": "int32"}},
                                                                                                                                                                            "body": {
                                                                                                                                                                              "lambda": {
                                                                                                                                                                                "parameter": "acc2",
                                                                                                                                                                                "domain": {"list": {"variable": "hydra.core.model.Name"}},
                                                                                                                                                                                "body": {
                                                                                                                                                                                  "let": {
                                                                                                                                                                                    "bindings": [
                                                                                                                                                                                      {
                                                                                                                                                                                        "name": "ti",
                                                                                                                                                                                        "term": {
                                                                                                                                                                                          "wrap": {
                                                                                                                                                                                            "typeName": "hydra.core.model.Name",
                                                                                                                                                                                            "body": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {"application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "t"}}}},
                                                                                                                                                                                                "argument": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {"variable": "hydra.core.lib.literals.printInt32"},
                                                                                                                                                                                                    "argument": {
                                                                                                                                                                                                      "application": {
                                                                                                                                                                                                        "function": {
                                                                                                                                                                                                          "application": {
                                                                                                                                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.add"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                                                                            "argument": {"variable": "next"}}},
                                                                                                                                                                                                        "argument": {"variable": "i"}}}}}}}}},
                                                                                                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                                                                                                                    "body": {
                                                                                                                                                                                      "application": {
                                                                                                                                                                                        "function": {
                                                                                                                                                                                          "application": {
                                                                                                                                                                                            "function": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {
                                                                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                                                                                                                                "argument": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {
                                                                                                                                                                                                      "application": {
                                                                                                                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                                                                        "argument": {"variable": "rem"}}},
                                                                                                                                                                                                    "argument": {"literal": {"integer": {"int32": 0}}}}}}},
                                                                                                                                                                                            "argument": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {
                                                                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.reverse"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                "argument": {"variable": "acc2"}}}}},
                                                                                                                                                                                        "argument": {
                                                                                                                                                                                          "application": {
                                                                                                                                                                                            "function": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {"variable": "gen"},
                                                                                                                                                                                                    "argument": {
                                                                                                                                                                                                      "application": {
                                                                                                                                                                                                        "function": {
                                                                                                                                                                                                          "application": {
                                                                                                                                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.add"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                                                                            "argument": {"variable": "i"}}},
                                                                                                                                                                                                        "argument": {"literal": {"integer": {"int32": 1}}}}}}},
                                                                                                                                                                                                "argument": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {
                                                                                                                                                                                                      "application": {
                                                                                                                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.sub"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                                                                        "argument": {"variable": "rem"}}},
                                                                                                                                                                                                    "argument": {"literal": {"integer": {"int32": 1}}}}}}},
                                                                                                                                                                                            "argument": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                    "argument": {"variable": "ti"}}},
                                                                                                                                                                                                "argument": {"variable": "acc2"}}}}}}}}}}}}}}},
                                                                                                                                                                    "typeScheme": {
                                                                                                                                                                      "variables": [],
                                                                                                                                                                      "body": {
                                                                                                                                                                        "function": {
                                                                                                                                                                          "domain": {"literal": {"integer": "int32"}},
                                                                                                                                                                          "codomain": {
                                                                                                                                                                            "function": {
                                                                                                                                                                              "domain": {"literal": {"integer": "int32"}},
                                                                                                                                                                              "codomain": {
                                                                                                                                                                                "function": {"domain": {"list": {"variable": "hydra.core.model.Name"}}, "codomain": {"list": {"variable": "hydra.core.model.Name"}}}}}}}},
                                                                                                                                                                      "constraints": []}}],
                                                                                                                                                                "body": {
                                                                                                                                                                  "let": {
                                                                                                                                                                    "bindings": [
                                                                                                                                                                      {
                                                                                                                                                                        "name": "newVars",
                                                                                                                                                                        "term": {
                                                                                                                                                                          "application": {
                                                                                                                                                                            "function": {
                                                                                                                                                                              "application": {
                                                                                                                                                                                "function": {"application": {"function": {"variable": "gen"}, "argument": {"literal": {"integer": {"int32": 0}}}}},
                                                                                                                                                                                "argument": {"variable": "k"}}},
                                                                                                                                                                            "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                                                                                                                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                                                                                                                                    "body": {
                                                                                                                                                                      "let": {
                                                                                                                                                                        "bindings": [
                                                                                                                                                                          {
                                                                                                                                                                            "name": "newSubst",
                                                                                                                                                                            "term": {
                                                                                                                                                                              "application": {
                                                                                                                                                                                "function": {
                                                                                                                                                                                  "application": {
                                                                                                                                                                                    "function": {
                                                                                                                                                                                      "typeApplication": {
                                                                                                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                    "argument": {
                                                                                                                                                                                      "application": {
                                                                                                                                                                                        "function": {
                                                                                                                                                                                          "typeApplication": {
                                                                                                                                                                                            "body": {
                                                                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                            "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                        "argument": {
                                                                                                                                                                                          "application": {
                                                                                                                                                                                            "function": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {
                                                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.zip"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                "argument": {"variable": "vars"}}},
                                                                                                                                                                                            "argument": {"variable": "newVars"}}}}}}},
                                                                                                                                                                                "argument": {"variable": "subst"}}},
                                                                                                                                                                            "typeScheme": {
                                                                                                                                                                              "variables": [],
                                                                                                                                                                              "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                              "constraints": []}}],
                                                                                                                                                                        "body": {
                                                                                                                                                                          "let": {
                                                                                                                                                                            "bindings": [
                                                                                                                                                                              {
                                                                                                                                                                                "name": "newBound",
                                                                                                                                                                                "term": {
                                                                                                                                                                                  "application": {
                                                                                                                                                                                    "function": {
                                                                                                                                                                                      "application": {
                                                                                                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                        "argument": {"variable": "boundVars"}}},
                                                                                                                                                                                    "argument": {
                                                                                                                                                                                      "application": {
                                                                                                                                                                                        "function": {
                                                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                        "argument": {"variable": "newVars"}}}}},
                                                                                                                                                                                "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                                                                                                                                            "body": {
                                                                                                                                                                              "let": {
                                                                                                                                                                                "bindings": [
                                                                                                                                                                                  {
                                                                                                                                                                                    "name": "newVal",
                                                                                                                                                                                    "term": {
                                                                                                                                                                                      "application": {
                                                                                                                                                                                        "function": {
                                                                                                                                                                                          "application": {
                                                                                                                                                                                            "function": {"variable": "rewriteWithSubst"},
                                                                                                                                                                                            "argument": {
                                                                                                                                                                                              "typeApplication": {
                                                                                                                                                                                                "body": {
                                                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                                                    "body": {
                                                                                                                                                                                                      "pair": {
                                                                                                                                                                                                        "first": {
                                                                                                                                                                                                          "typeApplication": {
                                                                                                                                                                                                            "body": {
                                                                                                                                                                                                              "typeApplication": {
                                                                                                                                                                                                                "body": {"pair": {"first": {"variable": "newSubst"}, "second": {"variable": "newBound"}}},
                                                                                                                                                                                                                "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                                                                                                                                                            "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                                                                                                                                        "second": {
                                                                                                                                                                                                          "application": {
                                                                                                                                                                                                            "function": {
                                                                                                                                                                                                              "application": {
                                                                                                                                                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.add"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                                                                                                                "argument": {"variable": "next"}}},
                                                                                                                                                                                                            "argument": {"variable": "k"}}}}},
                                                                                                                                                                                                    "type": {
                                                                                                                                                                                                      "pair": {
                                                                                                                                                                                                        "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                        "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                                                                                                                                                                "type": {"literal": {"integer": "int32"}}}}}},
                                                                                                                                                                                        "argument": {
                                                                                                                                                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}},
                                                                                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                                                                                                                "body": {
                                                                                                                                                                                  "let": {
                                                                                                                                                                                    "bindings": [
                                                                                                                                                                                      {
                                                                                                                                                                                        "name": "renameConstraintKeys",
                                                                                                                                                                                        "term": {
                                                                                                                                                                                          "typeLambda": {
                                                                                                                                                                                            "parameter": "t0",
                                                                                                                                                                                            "body": {
                                                                                                                                                                                              "lambda": {
                                                                                                                                                                                                "parameter": "constraintMap",
                                                                                                                                                                                                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "t0"}}},
                                                                                                                                                                                                "body": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {
                                                                                                                                                                                                      "typeApplication": {
                                                                                                                                                                                                        "body": {
                                                                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                        "type": {"variable": "t0"}}},
                                                                                                                                                                                                    "argument": {
                                                                                                                                                                                                      "application": {
                                                                                                                                                                                                        "function": {
                                                                                                                                                                                                          "application": {
                                                                                                                                                                                                            "function": {
                                                                                                                                                                                                              "typeApplication": {
                                                                                                                                                                                                                "body": {
                                                                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                                                                    "body": {"variable": "hydra.core.lib.lists.map"},
                                                                                                                                                                                                                    "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "t0"}}}}},
                                                                                                                                                                                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "t0"}}}}},
                                                                                                                                                                                                            "argument": {
                                                                                                                                                                                                              "lambda": {
                                                                                                                                                                                                                "parameter": "p",
                                                                                                                                                                                                                "domain": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "t0"}}},
                                                                                                                                                                                                                "body": {
                                                                                                                                                                                                                  "let": {
                                                                                                                                                                                                                    "bindings": [
                                                                                                                                                                                                                      {
                                                                                                                                                                                                                        "name": "oldName",
                                                                                                                                                                                                                        "term": {
                                                                                                                                                                                                                          "application": {
                                                                                                                                                                                                                            "function": {
                                                                                                                                                                                                                              "typeApplication": {
                                                                                                                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                                                "type": {"variable": "t0"}}},
                                                                                                                                                                                                                            "argument": {"variable": "p"}}},
                                                                                                                                                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                                                                                                                                                    "body": {
                                                                                                                                                                                                                      "let": {
                                                                                                                                                                                                                        "bindings": [
                                                                                                                                                                                                                          {
                                                                                                                                                                                                                            "name": "meta",
                                                                                                                                                                                                                            "term": {
                                                                                                                                                                                                                              "application": {
                                                                                                                                                                                                                                "function": {
                                                                                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                                                                                    "body": {
                                                                                                                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                                                    "type": {"variable": "t0"}}},
                                                                                                                                                                                                                                "argument": {"variable": "p"}}},
                                                                                                                                                                                                                            "typeScheme": {"variables": [], "body": {"variable": "t0"}, "constraints": []}}],
                                                                                                                                                                                                                        "body": {
                                                                                                                                                                                                                          "let": {
                                                                                                                                                                                                                            "bindings": [
                                                                                                                                                                                                                              {
                                                                                                                                                                                                                                "name": "newName",
                                                                                                                                                                                                                                "term": {
                                                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                                                    "function": {
                                                                                                                                                                                                                                      "application": {
                                                                                                                                                                                                                                        "function": {
                                                                                                                                                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.withDefault"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                                                        "argument": {"variable": "oldName"}}},
                                                                                                                                                                                                                                    "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.Name"}}},
                                                                                                                                                                                                                                            "argument": {"variable": "oldName"}}},
                                                                                                                                                                                                                                        "argument": {"variable": "newSubst"}}}}},
                                                                                                                                                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                                                                                                                                                            "body": {
                                                                                                                                                                                                                              "typeApplication": {
                                                                                                                                                                                                                                "body": {
                                                                                                                                                                                                                                  "typeApplication": {
                                                                                                                                                                                                                                    "body": {"pair": {"first": {"variable": "newName"}, "second": {"variable": "meta"}}},
                                                                                                                                                                                                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                                                "type": {"variable": "t0"}}}}}}}}}}}}},
                                                                                                                                                                                                        "argument": {
                                                                                                                                                                                                          "application": {
                                                                                                                                                                                                            "function": {
                                                                                                                                                                                                              "typeApplication": {
                                                                                                                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                                                                                                "type": {"variable": "t0"}}},
                                                                                                                                                                                                            "argument": {"variable": "constraintMap"}}}}}}}}}}},
                                                                                                                                                                                        "typeScheme": {
                                                                                                                                                                                          "variables": ["t0"],
                                                                                                                                                                                          "body": {
                                                                                                                                                                                            "function": {
                                                                                                                                                                                              "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "t0"}}},
                                                                                                                                                                                              "codomain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "t0"}}}}},
                                                                                                                                                                                          "constraints": [{"key": "t0", "value": {"classes": []}}]}}],
                                                                                                                                                                                    "body": {
                                                                                                                                                                                      "let": {
                                                                                                                                                                                        "bindings": [
                                                                                                                                                                                          {
                                                                                                                                                                                            "name": "oldConstraints",
                                                                                                                                                                                            "term": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "constraints"}},
                                                                                                                                                                                                "argument": {"variable": "ts"}}},
                                                                                                                                                                                            "typeScheme": {
                                                                                                                                                                                              "variables": [],
                                                                                                                                                                                              "body": {
                                                                                                                                                                                                "map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
                                                                                                                                                                                              "constraints": []}}],
                                                                                                                                                                                        "body": {
                                                                                                                                                                                          "let": {
                                                                                                                                                                                            "bindings": [
                                                                                                                                                                                              {
                                                                                                                                                                                                "name": "newConstraints",
                                                                                                                                                                                                "term": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {
                                                                                                                                                                                                      "typeApplication": {"body": {"variable": "renameConstraintKeys"}, "type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
                                                                                                                                                                                                    "argument": {"variable": "oldConstraints"}}},
                                                                                                                                                                                                "typeScheme": {
                                                                                                                                                                                                  "variables": [],
                                                                                                                                                                                                  "body": {
                                                                                                                                                                                                    "map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
                                                                                                                                                                                                  "constraints": []}}],
                                                                                                                                                                                            "body": {
                                                                                                                                                                                              "let": {
                                                                                                                                                                                                "bindings": [
                                                                                                                                                                                                  {
                                                                                                                                                                                                    "name": "b1",
                                                                                                                                                                                                    "term": {
                                                                                                                                                                                                      "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": {"variable": "newVal"}},
                                                                                                                                                                                                          {
                                                                                                                                                                                                            "name": "typeScheme",
                                                                                                                                                                                                            "term": {
                                                                                                                                                                                                              "optional": {
                                                                                                                                                                                                                "record": {
                                                                                                                                                                                                                  "typeName": "hydra.core.model.TypeScheme",
                                                                                                                                                                                                                  "fields": [
                                                                                                                                                                                                                    {"name": "variables", "term": {"variable": "newVars"}},
                                                                                                                                                                                                                    {
                                                                                                                                                                                                                      "name": "body",
                                                                                                                                                                                                                      "term": {
                                                                                                                                                                                                                        "application": {
                                                                                                                                                                                                                          "function": {"application": {"function": {"variable": "substType"}, "argument": {"variable": "newSubst"}}},
                                                                                                                                                                                                                          "argument": {"variable": "typ"}}}},
                                                                                                                                                                                                                    {"name": "constraints", "term": {"variable": "newConstraints"}}]}}}}]}},
                                                                                                                                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Binding"}, "constraints": []}}],
                                                                                                                                                                                                "body": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {
                                                                                                                                                                                                      "application": {
                                                                                                                                                                                                        "function": {"variable": "step"},
                                                                                                                                                                                                        "argument": {
                                                                                                                                                                                                          "application": {
                                                                                                                                                                                                            "function": {
                                                                                                                                                                                                              "application": {
                                                                                                                                                                                                                "function": {
                                                                                                                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                                                                                                                "argument": {"variable": "b1"}}},
                                                                                                                                                                                                            "argument": {"variable": "acc"}}}}},
                                                                                                                                                                                                    "argument": {"variable": "tl"}}}}}}}}}}}}}}}}}}}}}}}}}}}}},
                                                                                                                                            "typeScheme": {
                                                                                                                                              "variables": [],
                                                                                                                                              "body": {
                                                                                                                                                "function": {"domain": {"variable": "hydra.core.model.TypeScheme"}, "codomain": {"list": {"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.TypeScheme"}}},
                                                                                                                                                        "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                                                                                                    "argument": {
                                                                                                                                                      "application": {
                                                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                                                                                                                        "argument": {"variable": "b"}}}}},
                                                                                                                                                "argument": {"variable": "noType"}}},
                                                                                                                                            "argument": {
                                                                                                                                              "lambda": {
                                                                                                                                                "parameter": "ts",
                                                                                                                                                "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                                                                                                "body": {"application": {"function": {"variable": "withType"}, "argument": {"variable": "ts"}}}}}}}}}}}}}}}}}}}}}}},
                                                                                                        "typeScheme": {
                                                                                                          "variables": [],
                                                                                                          "body": {
                                                                                                            "function": {
                                                                                                              "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                                                                                              "codomain": {
                                                                                                                "function": {
                                                                                                                  "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                                                                                                  "codomain": {"list": {"variable": "hydra.core.model.Binding"}}}}}},
                                                                                                          "constraints": []}}],
                                                                                                    "body": {
                                                                                                      "let": {
                                                                                                        "bindings": [
                                                                                                          {
                                                                                                            "name": "bindings1",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "step"},
                                                                                                                    "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Binding"}}}}},
                                                                                                                "argument": {"variable": "bindings0"}}},
                                                                                                            "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                                                        "body": {
                                                                                                          "inject": {
                                                                                                            "typeName": "hydra.core.model.Term",
                                                                                                            "field": {
                                                                                                              "name": "let",
                                                                                                              "term": {
                                                                                                                "record": {
                                                                                                                  "typeName": "hydra.core.model.Let",
                                                                                                                  "fields": [
                                                                                                                    {"name": "bindings", "term": {"variable": "bindings1"}},
                                                                                                                    {
                                                                                                                      "name": "body",
                                                                                                                      "term": {
                                                                                                                        "application": {
                                                                                                                          "function": {
                                                                                                                            "application": {
                                                                                                                              "function": {"variable": "rewriteWithSubst"},
                                                                                                                              "argument": {
                                                                                                                                "typeApplication": {
                                                                                                                                  "body": {
                                                                                                                                    "typeApplication": {
                                                                                                                                      "body": {
                                                                                                                                        "pair": {
                                                                                                                                          "first": {
                                                                                                                                            "typeApplication": {
                                                                                                                                              "body": {
                                                                                                                                                "typeApplication": {
                                                                                                                                                  "body": {"pair": {"first": {"variable": "subst"}, "second": {"variable": "boundVars"}}},
                                                                                                                                                  "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                                                                                              "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                                                                          "second": {"variable": "next"}}},
                                                                                                                                      "type": {
                                                                                                                                        "pair": {
                                                                                                                                          "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                                                                          "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                                                                                                  "type": {"literal": {"integer": "int32"}}}}}},
                                                                                                                          "argument": {"variable": "body0"}}}}]}}}}}}}}}}}}}}}},
                                                                                  {
                                                                                    "name": "typeApplication",
                                                                                    "handler": {
                                                                                      "lambda": {
                                                                                        "parameter": "tt",
                                                                                        "domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
                                                                                        "body": {
                                                                                          "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": "rewriteWithSubst"},
                                                                                                              "argument": {
                                                                                                                "typeApplication": {
                                                                                                                  "body": {
                                                                                                                    "typeApplication": {
                                                                                                                      "body": {
                                                                                                                        "pair": {
                                                                                                                          "first": {
                                                                                                                            "typeApplication": {
                                                                                                                              "body": {
                                                                                                                                "typeApplication": {
                                                                                                                                  "body": {"pair": {"first": {"variable": "subst"}, "second": {"variable": "boundVars"}}},
                                                                                                                                  "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                                                                              "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                                                          "second": {"variable": "next"}}},
                                                                                                                      "type": {
                                                                                                                        "pair": {
                                                                                                                          "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                                                          "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                                                                                  "type": {"literal": {"integer": "int32"}}}}}},
                                                                                                          "argument": {
                                                                                                            "application": {
                                                                                                              "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
                                                                                                              "argument": {"variable": "tt"}}}}}},
                                                                                                    {
                                                                                                      "name": "type",
                                                                                                      "term": {
                                                                                                        "application": {
                                                                                                          "function": {"application": {"function": {"variable": "substType"}, "argument": {"variable": "subst"}}},
                                                                                                          "argument": {
                                                                                                            "application": {
                                                                                                              "function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
                                                                                                              "argument": {"variable": "tt"}}}}}}]}}}}}}}},
                                                                                  {
                                                                                    "name": "typeLambda",
                                                                                    "handler": {
                                                                                      "lambda": {
                                                                                        "parameter": "ta",
                                                                                        "domain": {"variable": "hydra.core.model.TypeLambda"},
                                                                                        "body": {
                                                                                          "inject": {
                                                                                            "typeName": "hydra.core.model.Term",
                                                                                            "field": {
                                                                                              "name": "typeLambda",
                                                                                              "term": {
                                                                                                "record": {
                                                                                                  "typeName": "hydra.core.model.TypeLambda",
                                                                                                  "fields": [
                                                                                                    {
                                                                                                      "name": "parameter",
                                                                                                      "term": {
                                                                                                        "application": {
                                                                                                          "function": {
                                                                                                            "application": {
                                                                                                              "function": {"typeApplication": {"body": {"variable": "replaceName"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                              "argument": {"variable": "subst"}}},
                                                                                                          "argument": {
                                                                                                            "application": {
                                                                                                              "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "parameter"}},
                                                                                                              "argument": {"variable": "ta"}}}}}},
                                                                                                    {
                                                                                                      "name": "body",
                                                                                                      "term": {
                                                                                                        "application": {
                                                                                                          "function": {
                                                                                                            "application": {
                                                                                                              "function": {"variable": "rewriteWithSubst"},
                                                                                                              "argument": {
                                                                                                                "typeApplication": {
                                                                                                                  "body": {
                                                                                                                    "typeApplication": {
                                                                                                                      "body": {
                                                                                                                        "pair": {
                                                                                                                          "first": {
                                                                                                                            "typeApplication": {
                                                                                                                              "body": {
                                                                                                                                "typeApplication": {
                                                                                                                                  "body": {"pair": {"first": {"variable": "subst"}, "second": {"variable": "boundVars"}}},
                                                                                                                                  "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                                                                              "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                                                                          "second": {"variable": "next"}}},
                                                                                                                      "type": {
                                                                                                                        "pair": {
                                                                                                                          "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                                                          "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                                                                                  "type": {"literal": {"integer": "int32"}}}}}},
                                                                                                          "argument": {
                                                                                                            "application": {
                                                                                                              "function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "body"}},
                                                                                                              "argument": {"variable": "ta"}}}}}}]}}}}}}}}]}},
                                                                            "argument": {"variable": "term"}}}}}}},
                                                                "typeScheme": {
                                                                  "variables": [],
                                                                  "body": {
                                                                    "function": {
                                                                      "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                                                  "constraints": []}}],
                                                            "body": {
                                                              "application": {
                                                                "function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteTerm"}, "argument": {"variable": "rewrite"}}},
                                                                "argument": {"variable": "term0"}}}}}}}}}}}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {
                                    "function": {
                                      "domain": {
                                        "pair": {
                                          "first": {
                                            "pair": {
                                              "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                              "second": {"set": {"variable": "hydra.core.model.Name"}}}},
                                          "second": {"literal": {"integer": "int32"}}}},
                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                  "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {"variable": "rewriteWithSubst"},
                                    "argument": {
                                      "typeApplication": {
                                        "body": {
                                          "typeApplication": {
                                            "body": {
                                              "pair": {
                                                "first": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "pair": {
                                                            "first": {
                                                              "typeApplication": {
                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                            "second": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                        "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                    "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                "second": {"literal": {"integer": {"int32": 0}}}}},
                                            "type": {
                                              "pair": {
                                                "first": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                        "type": {"literal": {"integer": "int32"}}}}}},
                                "argument": {"variable": "term"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {"string": "Recursively replace the type variables of let bindings with the systematic type variables t0, t1, t2, ..."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.replaceFreeTermVariable",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "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": "tnew",
                    "domain": {"variable": "hydra.core.model.Term"},
                    "body": {
                      "lambda": {
                        "parameter": "term",
                        "domain": {"variable": "hydra.core.model.Term"},
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "rewrite",
                                "term": {
                                  "lambda": {
                                    "parameter": "recurse",
                                    "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                    "body": {
                                      "lambda": {
                                        "parameter": "t",
                                        "domain": {"variable": "hydra.core.model.Term"},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "cases": {
                                                "typeName": "hydra.core.model.Term",
                                                "default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "t"}}},
                                                "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": {
                                                              "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.equality.equal"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                "argument": {"variable": "v"}}},
                                                                            "argument": {"variable": "vold"}}}}},
                                                                    "argument": {"variable": "t"}}},
                                                                "argument": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "t"}}}}}}}}}},
                                                  {
                                                    "name": "variable",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "v",
                                                        "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": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "argument": {"variable": "v"}}},
                                                                        "argument": {"variable": "vold"}}}}},
                                                                "argument": {"variable": "tnew"}}},
                                                            "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "variable", "term": {"variable": "v"}}}}}}}}}]}},
                                            "argument": {"variable": "t"}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {
                                    "function": {
                                      "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                  "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteTerm"}, "argument": {"variable": "rewrite"}}},
                                "argument": {"variable": "term"}}}}}}}}}}},
            "annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Replace a free variable in a term"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.replaceFreeTypeVariable",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false},
            {"name": "arg2", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Type"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "v",
                "domain": {"variable": "hydra.core.model.Name"},
                "body": {
                  "lambda": {
                    "parameter": "rep",
                    "domain": {"variable": "hydra.core.model.Type"},
                    "body": {
                      "lambda": {
                        "parameter": "typ",
                        "domain": {"variable": "hydra.core.model.Type"},
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "mapExpr",
                                "term": {
                                  "lambda": {
                                    "parameter": "recurse",
                                    "domain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
                                    "body": {
                                      "lambda": {
                                        "parameter": "t",
                                        "domain": {"variable": "hydra.core.model.Type"},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "cases": {
                                                "typeName": "hydra.core.model.Type",
                                                "default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "t"}}},
                                                "cases": [
                                                  {
                                                    "name": "forall",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "ft",
                                                        "domain": {"variable": "hydra.core.model.ForallType"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "argument": {"variable": "v"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
                                                                            "argument": {"variable": "ft"}}}}}}},
                                                                "argument": {"variable": "t"}}},
                                                            "argument": {
                                                              "inject": {
                                                                "typeName": "hydra.core.model.Type",
                                                                "field": {
                                                                  "name": "forall",
                                                                  "term": {
                                                                    "record": {
                                                                      "typeName": "hydra.core.model.ForallType",
                                                                      "fields": [
                                                                        {
                                                                          "name": "parameter",
                                                                          "term": {
                                                                            "application": {
                                                                              "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
                                                                              "argument": {"variable": "ft"}}}},
                                                                        {
                                                                          "name": "body",
                                                                          "term": {
                                                                            "application": {
                                                                              "function": {"variable": "recurse"},
                                                                              "argument": {
                                                                                "application": {
                                                                                  "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "body"}},
                                                                                  "argument": {"variable": "ft"}}}}}}]}}}}}}}}}},
                                                  {
                                                    "name": "variable",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "v'",
                                                        "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.Type"}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "argument": {"variable": "v"}}},
                                                                        "argument": {"variable": "v'"}}}}},
                                                                "argument": {"variable": "rep"}}},
                                                            "argument": {"variable": "t"}}}}}}]}},
                                            "argument": {"variable": "t"}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {
                                    "function": {
                                      "domain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}}}},
                                  "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteType"}, "argument": {"variable": "mapExpr"}}},
                                "argument": {"variable": "typ"}}}}}}}}}}},
            "annotation": {
              "map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Replace free occurrences of a name in a type"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.substituteTypeVariables",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {
              "name": "arg0",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
              "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Type"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "subst",
                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                "body": {
                  "lambda": {
                    "parameter": "typ",
                    "domain": {"variable": "hydra.core.model.Type"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "replace",
                            "term": {
                              "lambda": {
                                "parameter": "recurse",
                                "domain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
                                "body": {
                                  "lambda": {
                                    "parameter": "typ",
                                    "domain": {"variable": "hydra.core.model.Type"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "cases": {
                                            "typeName": "hydra.core.model.Type",
                                            "default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "typ"}}},
                                            "cases": [
                                              {
                                                "name": "variable",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "n",
                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                    "body": {
                                                      "inject": {
                                                        "typeName": "hydra.core.model.Type",
                                                        "field": {
                                                          "name": "variable",
                                                          "term": {
                                                            "application": {
                                                              "function": {
                                                                "application": {
                                                                  "function": {
                                                                    "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.withDefault"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                  "argument": {"variable": "n"}}},
                                                              "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.Name"}}},
                                                                      "argument": {"variable": "n"}}},
                                                                  "argument": {"variable": "subst"}}}}}}}}}}}]}},
                                        "argument": {"variable": "typ"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {
                                  "domain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}}}},
                              "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteType"}, "argument": {"variable": "replace"}}},
                            "argument": {"variable": "typ"}}}}}}}}},
            "annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Substitute type variables in a type"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.substituteVariable",
        "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": "from",
                "domain": {"variable": "hydra.core.model.Name"},
                "body": {
                  "lambda": {
                    "parameter": "to",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "lambda": {
                        "parameter": "term",
                        "domain": {"variable": "hydra.core.model.Term"},
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "replace",
                                "term": {
                                  "lambda": {
                                    "parameter": "recurse",
                                    "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                    "body": {
                                      "lambda": {
                                        "parameter": "term",
                                        "domain": {"variable": "hydra.core.model.Term"},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "cases": {
                                                "typeName": "hydra.core.model.Term",
                                                "default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}},
                                                "cases": [
                                                  {
                                                    "name": "variable",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "x",
                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                        "body": {
                                                          "inject": {
                                                            "typeName": "hydra.core.model.Term",
                                                            "field": {
                                                              "name": "variable",
                                                              "term": {
                                                                "application": {
                                                                  "function": {
                                                                    "application": {
                                                                      "function": {
                                                                        "application": {
                                                                          "function": {
                                                                            "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                          "argument": {
                                                                            "application": {
                                                                              "function": {
                                                                                "application": {
                                                                                  "function": {
                                                                                    "typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                  "argument": {"variable": "x"}}},
                                                                              "argument": {"variable": "from"}}}}},
                                                                      "argument": {"variable": "to"}}},
                                                                  "argument": {"variable": "x"}}}}}}}}},
                                                  {
                                                    "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": {"variable": "hydra.core.model.Term"}}},
                                                                    "argument": {
                                                                      "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.Lambda", "fieldName": "parameter"}},
                                                                                "argument": {"variable": "l"}}}}},
                                                                        "argument": {"variable": "from"}}}}},
                                                                "argument": {"variable": "term"}}},
                                                            "argument": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}}}}}}}]}},
                                            "argument": {"variable": "term"}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {
                                    "function": {
                                      "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                  "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteTerm"}, "argument": {"variable": "replace"}}},
                                "argument": {"variable": "term"}}}}}}}}}}},
            "annotation": {
              "map": [
                {"key": {"variable": "description"}, "value": {"literal": {"string": "Substitute one variable for another in a term"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.substituteVariables",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {
              "name": "arg0",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
              "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Term"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "subst",
                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                "body": {
                  "lambda": {
                    "parameter": "term",
                    "domain": {"variable": "hydra.core.model.Term"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "replace",
                            "term": {
                              "lambda": {
                                "parameter": "recurse",
                                "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                "body": {
                                  "lambda": {
                                    "parameter": "term",
                                    "domain": {"variable": "hydra.core.model.Term"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "cases": {
                                            "typeName": "hydra.core.model.Term",
                                            "default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}},
                                            "cases": [
                                              {
                                                "name": "variable",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "n",
                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                    "body": {
                                                      "inject": {
                                                        "typeName": "hydra.core.model.Term",
                                                        "field": {
                                                          "name": "variable",
                                                          "term": {
                                                            "application": {
                                                              "function": {
                                                                "application": {
                                                                  "function": {
                                                                    "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.withDefault"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                  "argument": {"variable": "n"}}},
                                                              "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.Name"}}},
                                                                      "argument": {"variable": "n"}}},
                                                                  "argument": {"variable": "subst"}}}}}}}}}}},
                                              {
                                                "name": "lambda",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "l",
                                                    "domain": {"variable": "hydra.core.model.Lambda"},
                                                    "body": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                "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.Name"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
                                                                            "argument": {"variable": "l"}}}}},
                                                                    "argument": {"variable": "subst"}}}}},
                                                            "argument": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}}}},
                                                        "argument": {"lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Name"}, "body": {"variable": "term"}}}}}}}}]}},
                                        "argument": {"variable": "term"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {
                                  "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                              "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteTerm"}, "argument": {"variable": "replace"}}},
                            "argument": {"variable": "term"}}}}}}}}},
            "annotation": {
              "map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Substitute multiple variables in a term"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.variables.unshadowVariables",
        "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": "term0",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "f",
                        "term": {
                          "lambda": {
                            "parameter": "recurse",
                            "domain": {
                              "function": {
                                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                            "body": {
                              "lambda": {
                                "parameter": "m",
                                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                "body": {
                                  "lambda": {
                                    "parameter": "term",
                                    "domain": {"variable": "hydra.core.model.Term"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "cases": {
                                            "typeName": "hydra.core.model.Term",
                                            "default": {
                                              "application": {
                                                "function": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "m"}}},
                                                "argument": {"variable": "term"}}},
                                            "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": "domain",
                                                                "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": {
                                                                      "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": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "argument": {"variable": "v"}}},
                                                                                "argument": {"variable": "m"}}}}},
                                                                        "argument": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "v2",
                                                                                "term": {
                                                                                  "application": {
                                                                                    "function": {"application": {"function": {"variable": "hydra.core.variables.freshNameAvoiding"}, "argument": {"variable": "v"}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.keys"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                                                            "argument": {"variable": "m"}}}}}}},
                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "m2",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                "argument": {"variable": "v"}}},
                                                                                            "argument": {"variable": "v2"}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "argument": {"variable": "v2"}}},
                                                                                                "argument": {"variable": "v2"}}},
                                                                                            "argument": {"variable": "m"}}}}},
                                                                                    "typeScheme": {
                                                                                      "variables": [],
                                                                                      "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"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": "v2"}},
                                                                                            {"name": "domain", "term": {"variable": "domain"}},
                                                                                            {
                                                                                              "name": "body",
                                                                                              "term": {
                                                                                                "application": {
                                                                                                  "function": {
                                                                                                    "application": {
                                                                                                      "function": {"application": {"function": {"variable": "f"}, "argument": {"variable": "recurse"}}},
                                                                                                      "argument": {"variable": "m2"}}},
                                                                                                  "argument": {"variable": "body"}}}}]}}}}}}}}}}},
                                                                    "argument": {
                                                                      "inject": {
                                                                        "typeName": "hydra.core.model.Term",
                                                                        "field": {
                                                                          "name": "lambda",
                                                                          "term": {
                                                                            "record": {
                                                                              "typeName": "hydra.core.model.Lambda",
                                                                              "fields": [
                                                                                {"name": "parameter", "term": {"variable": "v"}},
                                                                                {"name": "domain", "term": {"variable": "domain"}},
                                                                                {
                                                                                  "name": "body",
                                                                                  "term": {
                                                                                    "application": {
                                                                                      "function": {
                                                                                        "application": {
                                                                                          "function": {"application": {"function": {"variable": "f"}, "argument": {"variable": "recurse"}}},
                                                                                          "argument": {
                                                                                            "application": {
                                                                                              "function": {
                                                                                                "application": {
                                                                                                  "function": {
                                                                                                    "application": {
                                                                                                      "function": {
                                                                                                        "typeApplication": {
                                                                                                          "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                          "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                      "argument": {"variable": "v"}}},
                                                                                                  "argument": {"variable": "v"}}},
                                                                                              "argument": {"variable": "m"}}}}},
                                                                                      "argument": {"variable": "body"}}}}]}}}}}}}}}}}}}}}},
                                              {
                                                "name": "let",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "lt",
                                                    "domain": {"variable": "hydra.core.model.Let"},
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "resolveBinding",
                                                            "term": {
                                                              "lambda": {
                                                                "parameter": "acc",
                                                                "domain": {
                                                                  "pair": {
                                                                    "first": {"list": {"variable": "hydra.core.model.Name"}},
                                                                    "second": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                "body": {
                                                                  "lambda": {
                                                                    "parameter": "b",
                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "bname",
                                                                            "term": {
                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}},
                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "resolved",
                                                                                "term": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                        "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                                    "argument": {"variable": "acc"}}},
                                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "mapSoFar",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                            "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                                        "argument": {"variable": "acc"}}},
                                                                                    "typeScheme": {
                                                                                      "variables": [],
                                                                                      "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                      "constraints": []}}],
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                "type": {
                                                                                                  "pair": {
                                                                                                    "first": {"list": {"variable": "hydra.core.model.Name"}},
                                                                                                    "second": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "argument": {"variable": "bname"}}},
                                                                                                "argument": {"variable": "mapSoFar"}}}}},
                                                                                        "argument": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "v2",
                                                                                                "term": {
                                                                                                  "application": {
                                                                                                    "function": {"application": {"function": {"variable": "hydra.core.variables.freshNameAvoiding"}, "argument": {"variable": "bname"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.keys"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "argument": {"variable": "mapSoFar"}}}}}}},
                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                            "body": {
                                                                                              "let": {
                                                                                                "bindings": [
                                                                                                  {
                                                                                                    "name": "extended",
                                                                                                    "term": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                "argument": {"variable": "bname"}}},
                                                                                                            "argument": {"variable": "v2"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "typeApplication": {
                                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                    "argument": {"variable": "v2"}}},
                                                                                                                "argument": {"variable": "v2"}}},
                                                                                                            "argument": {"variable": "mapSoFar"}}}}},
                                                                                                    "typeScheme": {
                                                                                                      "variables": [],
                                                                                                      "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                                      "constraints": []}}],
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "pair": {
                                                                                                            "first": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                    "argument": {"variable": "v2"}}},
                                                                                                                "argument": {"variable": "resolved"}}},
                                                                                                            "second": {"variable": "extended"}}},
                                                                                                        "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                                    "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}}}}}}}},
                                                                                    "argument": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "extended",
                                                                                            "term": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                        "argument": {"variable": "bname"}}},
                                                                                                    "argument": {"variable": "bname"}}},
                                                                                                "argument": {"variable": "mapSoFar"}}},
                                                                                            "typeScheme": {
                                                                                              "variables": [],
                                                                                              "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                              "constraints": []}}],
                                                                                        "body": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "pair": {
                                                                                                    "first": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "argument": {"variable": "bname"}}},
                                                                                                        "argument": {"variable": "resolved"}}},
                                                                                                    "second": {"variable": "extended"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                            "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}}}}}}}}}}}}}}}},
                                                            "typeScheme": {
                                                              "variables": [],
                                                              "body": {
                                                                "function": {
                                                                  "domain": {
                                                                    "pair": {
                                                                      "first": {"list": {"variable": "hydra.core.model.Name"}},
                                                                      "second": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                  "codomain": {
                                                                    "function": {
                                                                      "domain": {"variable": "hydra.core.model.Binding"},
                                                                      "codomain": {
                                                                        "pair": {
                                                                          "first": {"list": {"variable": "hydra.core.model.Name"}},
                                                                          "second": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}}}}}},
                                                              "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "resolvedState",
                                                                "term": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {
                                                                                    "body": {"variable": "hydra.core.lib.lists.foldl"},
                                                                                    "type": {
                                                                                      "pair": {
                                                                                        "first": {"list": {"variable": "hydra.core.model.Name"}},
                                                                                        "second": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}}}},
                                                                                "type": {"variable": "hydra.core.model.Binding"}}},
                                                                            "argument": {"variable": "resolveBinding"}}},
                                                                        "argument": {
                                                                          "typeApplication": {
                                                                            "body": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "pair": {
                                                                                    "first": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "second": {"variable": "m"}}},
                                                                                "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                            "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}}}},
                                                                    "argument": {
                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "lt"}}}}},
                                                                "typeScheme": {
                                                                  "variables": [],
                                                                  "body": {
                                                                    "pair": {
                                                                      "first": {"list": {"variable": "hydra.core.model.Name"}},
                                                                      "second": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                  "constraints": []}}],
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "resolvedNames",
                                                                    "term": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.reverse"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                            "argument": {"variable": "resolvedState"}}}}},
                                                                    "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "m2",
                                                                        "term": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                                "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                                                            "argument": {"variable": "resolvedState"}}},
                                                                        "typeScheme": {
                                                                          "variables": [],
                                                                          "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                          "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "renameBinding",
                                                                            "term": {
                                                                              "lambda": {
                                                                                "parameter": "p",
                                                                                "domain": {"pair": {"first": {"variable": "hydra.core.model.Binding"}, "second": {"variable": "hydra.core.model.Name"}}},
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "b",
                                                                                        "term": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                                                            "argument": {"variable": "p"}}},
                                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Binding"}, "constraints": []}}],
                                                                                    "body": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "newName",
                                                                                            "term": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                "argument": {"variable": "p"}}},
                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                                        "body": {
                                                                                          "record": {
                                                                                            "typeName": "hydra.core.model.Binding",
                                                                                            "fields": [
                                                                                              {"name": "name", "term": {"variable": "newName"}},
                                                                                              {
                                                                                                "name": "term",
                                                                                                "term": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "f"}, "argument": {"variable": "recurse"}}},
                                                                                                        "argument": {"variable": "m2"}}},
                                                                                                    "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": {"pair": {"first": {"variable": "hydra.core.model.Binding"}, "second": {"variable": "hydra.core.model.Name"}}},
                                                                                  "codomain": {"variable": "hydra.core.model.Binding"}}},
                                                                              "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "newBindings",
                                                                                "term": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {"variable": "hydra.core.lib.lists.map"},
                                                                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Binding"}, "second": {"variable": "hydra.core.model.Name"}}}}},
                                                                                            "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                        "argument": {"variable": "renameBinding"}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.zip"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                                                            "argument": {
                                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "lt"}}}}},
                                                                                        "argument": {"variable": "resolvedNames"}}}}},
                                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                            "body": {
                                                                              "inject": {
                                                                                "typeName": "hydra.core.model.Term",
                                                                                "field": {
                                                                                  "name": "let",
                                                                                  "term": {
                                                                                    "record": {
                                                                                      "typeName": "hydra.core.model.Let",
                                                                                      "fields": [
                                                                                        {"name": "bindings", "term": {"variable": "newBindings"}},
                                                                                        {
                                                                                          "name": "body",
                                                                                          "term": {
                                                                                            "application": {
                                                                                              "function": {
                                                                                                "application": {
                                                                                                  "function": {"application": {"function": {"variable": "f"}, "argument": {"variable": "recurse"}}},
                                                                                                  "argument": {"variable": "m2"}}},
                                                                                              "argument": {
                                                                                                "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "lt"}}}}}}]}}}}}}}}}}}}}}}}}}}},
                                              {
                                                "name": "variable",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "v",
                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                    "body": {
                                                      "inject": {
                                                        "typeName": "hydra.core.model.Term",
                                                        "field": {
                                                          "name": "variable",
                                                          "term": {
                                                            "application": {
                                                              "function": {
                                                                "application": {
                                                                  "function": {
                                                                    "application": {
                                                                      "function": {
                                                                        "typeApplication": {
                                                                          "body": {
                                                                            "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                          "type": {"variable": "hydra.core.model.Name"}}},
                                                                      "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.Name"}}},
                                                                              "argument": {"variable": "v"}}},
                                                                          "argument": {"variable": "m"}}}}},
                                                                  "argument": {"variable": "v"}}},
                                                              "argument": {"lambda": {"parameter": "renamed", "domain": {"variable": "hydra.core.model.Name"}, "body": {"variable": "renamed"}}}}}}}}}}}]}},
                                        "argument": {"variable": "term"}}}}}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {
                            "function": {
                              "domain": {
                                "function": {
                                  "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                              "codomain": {
                                "function": {
                                  "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}}}},
                          "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {
                                    "body": {"variable": "hydra.core.rewriting.rewriteTermWithContext"},
                                    "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
                                "argument": {"variable": "f"}}},
                            "argument": {
                              "typeApplication": {
                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                "type": {"variable": "hydra.core.model.Name"}}}}},
                        "argument": {"variable": "term0"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Rename all shadowed variables (both lambda parameters and let-bound variables that shadow lambda parameters) in a term."}}}]}}}}}]}