packages feed

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

{
  "name": "hydra.core.dependencies",
  "metadata": {
    "description": "Dependency extraction, binding sort, and let normalization",
    "comments": [],
    "seeAlso": [],
    "provisions": []},
  "dependencies": [
    {"module": "hydra.core.annotations"},
    {"module": "hydra.core.coders"},
    {"module": "hydra.core.constants"},
    {"module": "hydra.core.errors"},
    {"module": "hydra.core.lexical"},
    {"module": "hydra.core.lib.eithers"},
    {"module": "hydra.core.lib.equality"},
    {"module": "hydra.core.lib.lists"},
    {"module": "hydra.core.lib.literals"},
    {"module": "hydra.core.lib.logic"},
    {"module": "hydra.core.lib.maps"},
    {"module": "hydra.core.lib.math"},
    {"module": "hydra.core.lib.optionals"},
    {"module": "hydra.core.lib.ordering"},
    {"module": "hydra.core.lib.pairs"},
    {"module": "hydra.core.lib.sets"},
    {"module": "hydra.core.lib.strings"},
    {"module": "hydra.core.model"},
    {"module": "hydra.core.names"},
    {"module": "hydra.core.packaging"},
    {"module": "hydra.core.rewriting"},
    {"module": "hydra.core.sorting"},
    {"module": "hydra.core.strip"},
    {"module": "hydra.core.variables"}],
  "definitions": [
    {
      "term": {
        "name": "hydra.core.dependencies.definitionsWithDependencies",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg2", "type": {"list": {"variable": "hydra.core.model.Binding"}}, "isLazy": false}],
          "result": {
            "type": {
              "either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"list": {"variable": "hydra.core.model.Binding"}}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "cx",
                    "domain": {"variable": "t0"},
                    "body": {
                      "lambda": {
                        "parameter": "graph",
                        "domain": {"variable": "hydra.core.graph.Graph"},
                        "body": {
                          "lambda": {
                            "parameter": "original",
                            "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "depNames",
                                    "term": {
                                      "lambda": {
                                        "parameter": "el",
                                        "domain": {"variable": "hydra.core.model.Binding"},
                                        "body": {
                                          "application": {
                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {"function": {"variable": "hydra.core.dependencies.termDependencyNames"}, "argument": {"literal": {"boolean": true}}}},
                                                        "argument": {"literal": {"boolean": false}}}},
                                                    "argument": {"literal": {"boolean": false}}}},
                                                "argument": {
                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "el"}}}}}}}}},
                                    "typeScheme": {
                                      "variables": [],
                                      "body": {
                                        "function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"list": {"variable": "hydra.core.model.Name"}}}},
                                      "constraints": []}}],
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "allDepNames",
                                        "term": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.distinct"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat2"}, "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": {"variable": "original"}}}}},
                                                "argument": {
                                                  "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.Binding"}}},
                                                                "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                            "argument": {"variable": "depNames"}}},
                                                        "argument": {"variable": "original"}}}}}}}}},
                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.mapList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                    "type": {"variable": "hydra.core.model.Binding"}}},
                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                            "argument": {
                                              "lambda": {
                                                "parameter": "name",
                                                "domain": {"variable": "hydra.core.model.Name"},
                                                "body": {
                                                  "application": {
                                                    "function": {"application": {"function": {"variable": "hydra.core.lexical.requireBinding"}, "argument": {"variable": "graph"}}},
                                                    "argument": {"variable": "name"}}}}}}},
                                        "argument": {"variable": "allDepNames"}}}}}}}}}}}}},
                "annotation": {
                  "map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Get definitions with their dependencies"}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.flattenLetTerms",
        "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": "rewriteBinding",
                        "term": {
                          "lambda": {
                            "parameter": "binding",
                            "domain": {"variable": "hydra.core.model.Binding"},
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "key0",
                                    "term": {
                                      "application": {
                                        "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}},
                                        "argument": {"variable": "binding"}}},
                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "val0",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}},
                                            "argument": {"variable": "binding"}}},
                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "t",
                                            "term": {
                                              "application": {
                                                "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                "argument": {"variable": "binding"}}},
                                            "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.TypeScheme"}}, "constraints": []}}],
                                        "body": {
                                          "application": {
                                            "function": {
                                              "cases": {
                                                "typeName": "hydra.core.model.Term",
                                                "default": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "pair": {
                                                            "first": {
                                                              "record": {
                                                                "typeName": "hydra.core.model.Binding",
                                                                "fields": [
                                                                  {"name": "name", "term": {"variable": "key0"}},
                                                                  {"name": "term", "term": {"variable": "val0"}},
                                                                  {"name": "typeScheme", "term": {"variable": "t"}}]}},
                                                            "second": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Binding"}}}}},
                                                        "type": {"variable": "hydra.core.model.Binding"}}},
                                                    "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                "cases": [
                                                  {
                                                    "name": "annotated",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "at",
                                                        "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "val1",
                                                                "term": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                    "argument": {"variable": "at"}}},
                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "ann",
                                                                    "term": {
                                                                      "application": {
                                                                        "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "annotation"}},
                                                                        "argument": {"variable": "at"}}},
                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "recursive",
                                                                        "term": {
                                                                          "application": {
                                                                            "function": {"variable": "rewriteBinding"},
                                                                            "argument": {
                                                                              "record": {
                                                                                "typeName": "hydra.core.model.Binding",
                                                                                "fields": [
                                                                                  {"name": "name", "term": {"variable": "key0"}},
                                                                                  {"name": "term", "term": {"variable": "val1"}},
                                                                                  {"name": "typeScheme", "term": {"variable": "t"}}]}}}},
                                                                        "typeScheme": {
                                                                          "variables": [],
                                                                          "body": {
                                                                            "pair": {"first": {"variable": "hydra.core.model.Binding"}, "second": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                          "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "innerBinding",
                                                                            "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": "recursive"}}},
                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Binding"}, "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "deps",
                                                                                "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": "recursive"}}},
                                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "val2",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}},
                                                                                        "argument": {"variable": "innerBinding"}}},
                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                "body": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "pair": {
                                                                                            "first": {
                                                                                              "record": {
                                                                                                "typeName": "hydra.core.model.Binding",
                                                                                                "fields": [
                                                                                                  {"name": "name", "term": {"variable": "key0"}},
                                                                                                  {
                                                                                                    "name": "term",
                                                                                                    "term": {
                                                                                                      "inject": {
                                                                                                        "typeName": "hydra.core.model.Term",
                                                                                                        "field": {
                                                                                                          "name": "annotated",
                                                                                                          "term": {
                                                                                                            "record": {
                                                                                                              "typeName": "hydra.core.model.AnnotatedTerm",
                                                                                                              "fields": [{"name": "body", "term": {"variable": "val2"}}, {"name": "annotation", "term": {"variable": "ann"}}]}}}}}},
                                                                                                  {"name": "typeScheme", "term": {"variable": "t"}}]}},
                                                                                            "second": {"variable": "deps"}}},
                                                                                        "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                    "type": {"list": {"variable": "hydra.core.model.Binding"}}}}}}}}}}}}}}}}}}},
                                                  {
                                                    "name": "let",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "innerLet",
                                                        "domain": {"variable": "hydra.core.model.Let"},
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "bindings1",
                                                                "term": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}},
                                                                    "argument": {"variable": "innerLet"}}},
                                                                "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "body1",
                                                                    "term": {
                                                                      "application": {
                                                                        "function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}},
                                                                        "argument": {"variable": "innerLet"}}},
                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "prefix",
                                                                        "term": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                                                "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "key0"}}}}},
                                                                            "argument": {"literal": {"string": "_"}}}},
                                                                        "typeScheme": {"variables": [], "body": {"literal": "string"}, "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "qualify",
                                                                            "term": {
                                                                              "lambda": {
                                                                                "parameter": "n",
                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                "body": {
                                                                                  "wrap": {
                                                                                    "typeName": "hydra.core.model.Name",
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {"application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"variable": "prefix"}}},
                                                                                        "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "n"}}}}}}}}},
                                                                            "typeScheme": {
                                                                              "variables": [],
                                                                              "body": {"function": {"domain": {"variable": "hydra.core.model.Name"}, "codomain": {"variable": "hydra.core.model.Name"}}},
                                                                              "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "toSubstPair",
                                                                                "term": {
                                                                                  "lambda": {
                                                                                    "parameter": "b",
                                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                                    "body": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "pair": {
                                                                                                "first": {
                                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}},
                                                                                                "second": {
                                                                                                  "application": {
                                                                                                    "function": {"variable": "qualify"},
                                                                                                    "argument": {
                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}}}}},
                                                                                            "type": {"variable": "hydra.core.model.Name"}}},
                                                                                        "type": {"variable": "hydra.core.model.Name"}}}}},
                                                                                "typeScheme": {
                                                                                  "variables": [],
                                                                                  "body": {
                                                                                    "function": {
                                                                                      "domain": {"variable": "hydra.core.model.Binding"},
                                                                                      "codomain": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Name"}}}}},
                                                                                  "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "subst",
                                                                                    "term": {
                                                                                      "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.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                    "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Name"}}}}},
                                                                                                "argument": {"variable": "toSubstPair"}}},
                                                                                            "argument": {"variable": "bindings1"}}}}},
                                                                                    "typeScheme": {
                                                                                      "variables": [],
                                                                                      "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}},
                                                                                      "constraints": []}}],
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "replaceVars",
                                                                                        "term": {
                                                                                          "application": {"function": {"variable": "hydra.core.variables.substituteVariables"}, "argument": {"variable": "subst"}}},
                                                                                        "typeScheme": {
                                                                                          "variables": [],
                                                                                          "body": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                                                                          "constraints": []}}],
                                                                                    "body": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "newBody",
                                                                                            "term": {"application": {"function": {"variable": "replaceVars"}, "argument": {"variable": "body1"}}},
                                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                        "body": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "newBinding",
                                                                                                "term": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "b",
                                                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                    "body": {
                                                                                                      "record": {
                                                                                                        "typeName": "hydra.core.model.Binding",
                                                                                                        "fields": [
                                                                                                          {
                                                                                                            "name": "name",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {"variable": "qualify"},
                                                                                                                "argument": {
                                                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}}}},
                                                                                                          {
                                                                                                            "name": "term",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {"variable": "replaceVars"},
                                                                                                                "argument": {
                                                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}}},
                                                                                                          {
                                                                                                            "name": "typeScheme",
                                                                                                            "term": {
                                                                                                              "application": {
                                                                                                                "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                                                                                "argument": {"variable": "b"}}}}]}}}},
                                                                                                "typeScheme": {
                                                                                                  "variables": [],
                                                                                                  "body": {"function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"variable": "hydra.core.model.Binding"}}},
                                                                                                  "constraints": []}}],
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "pair": {
                                                                                                        "first": {
                                                                                                          "record": {
                                                                                                            "typeName": "hydra.core.model.Binding",
                                                                                                            "fields": [
                                                                                                              {"name": "name", "term": {"variable": "key0"}},
                                                                                                              {"name": "term", "term": {"variable": "newBody"}},
                                                                                                              {"name": "typeScheme", "term": {"variable": "t"}}]}},
                                                                                                        "second": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {
                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                    "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                                "argument": {"variable": "newBinding"}}},
                                                                                                            "argument": {"variable": "bindings1"}}}}},
                                                                                                    "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.model.Binding"}}}}}}}}}}}}}}}}}}}}}}}}}]}},
                                            "argument": {"variable": "val0"}}}}}}}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {
                            "function": {
                              "domain": {"variable": "hydra.core.model.Binding"},
                              "codomain": {
                                "pair": {"first": {"variable": "hydra.core.model.Binding"}, "second": {"list": {"variable": "hydra.core.model.Binding"}}}}}},
                          "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "flattenBodyLet",
                            "term": {
                              "lambda": {
                                "parameter": "bindings",
                                "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                "body": {
                                  "lambda": {
                                    "parameter": "body",
                                    "domain": {"variable": "hydra.core.model.Term"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "cases": {
                                            "typeName": "hydra.core.model.Term",
                                            "default": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "pair": {
                                                        "first": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat2"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Binding"}}}}},
                                                            "argument": {"variable": "bindings"}}},
                                                        "second": {"variable": "body"}}},
                                                    "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                "type": {"variable": "hydra.core.model.Term"}}},
                                            "cases": [
                                              {
                                                "name": "let",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "innerLt",
                                                    "domain": {"variable": "hydra.core.model.Let"},
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "innerBindings",
                                                            "term": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}},
                                                                "argument": {"variable": "innerLt"}}},
                                                            "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "innerBody",
                                                                "term": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}},
                                                                    "argument": {"variable": "innerLt"}}},
                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {"variable": "flattenBodyLet"},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat2"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                            "argument": {"variable": "bindings"}}},
                                                                        "argument": {"variable": "innerBindings"}}}}},
                                                                "argument": {"variable": "innerBody"}}}}}}}}}}]}},
                                        "argument": {"variable": "body"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {
                                  "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                  "codomain": {
                                    "function": {
                                      "domain": {"variable": "hydra.core.model.Term"},
                                      "codomain": {"pair": {"first": {"list": {"variable": "hydra.core.model.Binding"}}, "second": {"variable": "hydra.core.model.Term"}}}}}}},
                              "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "flatten",
                                "term": {
                                  "typeLambda": {
                                    "parameter": "t0",
                                    "body": {
                                      "lambda": {
                                        "parameter": "recurse",
                                        "domain": {"function": {"domain": {"variable": "t0"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                        "body": {
                                          "lambda": {
                                            "parameter": "term",
                                            "domain": {"variable": "t0"},
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "rewritten",
                                                    "term": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}},
                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "cases": {
                                                        "typeName": "hydra.core.model.Term",
                                                        "default": {"variable": "rewritten"},
                                                        "cases": [
                                                          {
                                                            "name": "let",
                                                            "handler": {
                                                              "lambda": {
                                                                "parameter": "lt",
                                                                "domain": {"variable": "hydra.core.model.Let"},
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "bindings",
                                                                        "term": {
                                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "lt"}}},
                                                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "body",
                                                                            "term": {
                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "lt"}}},
                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "forResult",
                                                                                "term": {
                                                                                  "typeLambda": {
                                                                                    "parameter": "t1",
                                                                                    "body": {
                                                                                      "lambda": {
                                                                                        "parameter": "hr",
                                                                                        "domain": {"pair": {"first": {"variable": "t1"}, "second": {"list": {"variable": "t1"}}}},
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat2"}, "type": {"variable": "t1"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "t1"}}},
                                                                                                        "type": {"list": {"variable": "t1"}}}},
                                                                                                    "argument": {"variable": "hr"}}}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.singleton"}, "type": {"variable": "t1"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "t1"}}},
                                                                                                        "type": {"list": {"variable": "t1"}}}},
                                                                                                    "argument": {"variable": "hr"}}}}}}}}}}},
                                                                                "typeScheme": {
                                                                                  "variables": ["t1"],
                                                                                  "body": {
                                                                                    "function": {
                                                                                      "domain": {"pair": {"first": {"variable": "t1"}, "second": {"list": {"variable": "t1"}}}},
                                                                                      "codomain": {"list": {"variable": "t1"}}}},
                                                                                  "constraints": [{"key": "t1", "value": {"classes": []}}]}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "flattenedBindings",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                    "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                                                "argument": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "arg_",
                                                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"typeApplication": {"body": {"variable": "forResult"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                                                        "argument": {"application": {"function": {"variable": "rewriteBinding"}, "argument": {"variable": "arg_"}}}}}}}}},
                                                                                            "argument": {"variable": "bindings"}}}}},
                                                                                    "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                                "body": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "merged",
                                                                                        "term": {
                                                                                          "application": {
                                                                                            "function": {"application": {"function": {"variable": "flattenBodyLet"}, "argument": {"variable": "flattenedBindings"}}},
                                                                                            "argument": {"variable": "body"}}},
                                                                                        "typeScheme": {
                                                                                          "variables": [],
                                                                                          "body": {"pair": {"first": {"list": {"variable": "hydra.core.model.Binding"}}, "second": {"variable": "hydra.core.model.Term"}}},
                                                                                          "constraints": []}}],
                                                                                    "body": {
                                                                                      "let": {
                                                                                        "bindings": [
                                                                                          {
                                                                                            "name": "newBindings",
                                                                                            "term": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                "argument": {"variable": "merged"}}},
                                                                                            "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                                                                        "body": {
                                                                                          "let": {
                                                                                            "bindings": [
                                                                                              {
                                                                                                "name": "newBody",
                                                                                                "term": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                                                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                                                                    "argument": {"variable": "merged"}}},
                                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "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": {"variable": "newBody"}}]}}}}}}}}}}}}}}}}}}}}}}]}},
                                                    "argument": {"variable": "rewritten"}}}}}}}}}}},
                                "typeScheme": {
                                  "variables": ["t0"],
                                  "body": {
                                    "function": {
                                      "domain": {"function": {"domain": {"variable": "t0"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                      "codomain": {"function": {"domain": {"variable": "t0"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                  "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {"variable": "hydra.core.rewriting.rewriteTerm"},
                                    "argument": {"typeApplication": {"body": {"variable": "flatten"}, "type": {"variable": "hydra.core.model.Term"}}}}},
                                "argument": {"variable": "term"}}}}}}}}}}},
            "annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Flatten nested let expressions"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.inlineType",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {
              "name": "arg0",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Type"}}},
              "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "schema",
                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Type"}}},
                "body": {
                  "lambda": {
                    "parameter": "typ",
                    "domain": {"variable": "hydra.core.model.Type"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "f",
                            "term": {
                              "typeLambda": {
                                "parameter": "t0",
                                "body": {
                                  "lambda": {
                                    "parameter": "recurse",
                                    "domain": {
                                      "function": {
                                        "domain": {"variable": "t0"},
                                        "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
                                    "body": {
                                      "lambda": {
                                        "parameter": "typ",
                                        "domain": {"variable": "t0"},
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "afterRecurse",
                                                "term": {
                                                  "lambda": {
                                                    "parameter": "tr",
                                                    "domain": {"variable": "hydra.core.model.Type"},
                                                    "body": {
                                                      "application": {
                                                        "function": {
                                                          "cases": {
                                                            "typeName": "hydra.core.model.Type",
                                                            "default": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {"body": {"either": {"right": {"variable": "tr"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                "type": {"variable": "hydra.core.model.Type"}}},
                                                            "cases": [
                                                              {
                                                                "name": "variable",
                                                                "handler": {
                                                                  "lambda": {
                                                                    "parameter": "v",
                                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                    "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
                                                                                "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.Type"}}},
                                                                                        "argument": {"variable": "v"}}},
                                                                                    "argument": {"variable": "schema"}}}}},
                                                                            "argument": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "either": {
                                                                                        "left": {
                                                                                          "inject": {
                                                                                            "typeName": "hydra.core.errors.Error",
                                                                                            "field": {
                                                                                              "name": "other",
                                                                                              "term": {
                                                                                                "wrap": {
                                                                                                  "typeName": "hydra.core.errors.OtherError",
                                                                                                  "body": {
                                                                                                    "application": {
                                                                                                      "function": {
                                                                                                        "application": {
                                                                                                          "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                                                                          "argument": {"literal": {"string": "No such type in schema: "}}}},
                                                                                                      "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "v"}}}}}}}}}}}},
                                                                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                "type": {"variable": "hydra.core.model.Type"}}}}},
                                                                        "argument": {"application": {"function": {"variable": "hydra.core.dependencies.inlineType"}, "argument": {"variable": "schema"}}}}}}}}]}},
                                                        "argument": {"variable": "tr"}}}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {
                                                    "function": {
                                                      "domain": {"variable": "hydra.core.model.Type"},
                                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                            "type": {"variable": "hydra.core.model.Type"}}},
                                                        "type": {"variable": "hydra.core.model.Type"}}},
                                                    "argument": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "typ"}}}}},
                                                "argument": {
                                                  "lambda": {
                                                    "parameter": "tr",
                                                    "domain": {"variable": "hydra.core.model.Type"},
                                                    "body": {"application": {"function": {"variable": "afterRecurse"}, "argument": {"variable": "tr"}}}}}}}}}}}}}}},
                            "typeScheme": {
                              "variables": ["t0"],
                              "body": {
                                "function": {
                                  "domain": {
                                    "function": {
                                      "domain": {"variable": "t0"},
                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}},
                                  "codomain": {
                                    "function": {
                                      "domain": {"variable": "t0"},
                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Type"}}}}}}},
                              "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {"body": {"variable": "hydra.core.rewriting.rewriteTypeM"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                "argument": {"typeApplication": {"body": {"variable": "f"}, "type": {"variable": "hydra.core.model.Type"}}}}},
                            "argument": {"variable": "typ"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Inline all type variables in a type using the provided schema (Either version). Note: this function is only appropriate for nonrecursive type definitions"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.isLambda",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"literal": "boolean"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "term",
                "domain": {"variable": "hydra.core.model.Term"},
                "body": {
                  "application": {
                    "function": {
                      "cases": {
                        "typeName": "hydra.core.model.Term",
                        "default": {"literal": {"boolean": false}},
                        "cases": [
                          {
                            "name": "lambda",
                            "handler": {
                              "lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Lambda"}, "body": {"literal": {"boolean": true}}}}},
                          {
                            "name": "let",
                            "handler": {
                              "lambda": {
                                "parameter": "lt",
                                "domain": {"variable": "hydra.core.model.Let"},
                                "body": {
                                  "application": {
                                    "function": {"variable": "hydra.core.dependencies.isLambda"},
                                    "argument": {
                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "lt"}}}}}}}}]}},
                    "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "term"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Check whether a term is a lambda, possibly nested within let and/or annotation terms"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.liftLambdaAboveLet",
        "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": "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": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "rewriteBinding",
                                        "term": {
                                          "lambda": {
                                            "parameter": "b",
                                            "domain": {"variable": "hydra.core.model.Binding"},
                                            "body": {
                                              "record": {
                                                "typeName": "hydra.core.model.Binding",
                                                "fields": [
                                                  {
                                                    "name": "name",
                                                    "term": {
                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}},
                                                  {
                                                    "name": "term",
                                                    "term": {
                                                      "application": {
                                                        "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"variable": "recurse"}}},
                                                        "argument": {
                                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}}},
                                                  {
                                                    "name": "typeScheme",
                                                    "term": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                        "argument": {"variable": "b"}}}}]}}}},
                                        "typeScheme": {
                                          "variables": [],
                                          "body": {"function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"variable": "hydra.core.model.Binding"}}},
                                          "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "rewriteBindings",
                                            "term": {
                                              "lambda": {
                                                "parameter": "bs",
                                                "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                            "type": {"variable": "hydra.core.model.Binding"}}},
                                                        "argument": {"variable": "rewriteBinding"}}},
                                                    "argument": {"variable": "bs"}}}}},
                                            "typeScheme": {
                                              "variables": [],
                                              "body": {
                                                "function": {
                                                  "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                                                  "codomain": {"list": {"variable": "hydra.core.model.Binding"}}}},
                                              "constraints": []}}],
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "digForLambdas",
                                                "term": {
                                                  "lambda": {
                                                    "parameter": "original",
                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "cons",
                                                        "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": "original"}}},
                                                                    "cases": [
                                                                      {
                                                                        "name": "annotated",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "at",
                                                                            "domain": {"variable": "hydra.core.model.AnnotatedTerm"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"application": {"function": {"variable": "digForLambdas"}, "argument": {"variable": "original"}}},
                                                                                    "argument": {
                                                                                      "lambda": {
                                                                                        "parameter": "t",
                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                        "body": {
                                                                                          "inject": {
                                                                                            "typeName": "hydra.core.model.Term",
                                                                                            "field": {
                                                                                              "name": "annotated",
                                                                                              "term": {
                                                                                                "record": {
                                                                                                  "typeName": "hydra.core.model.AnnotatedTerm",
                                                                                                  "fields": [
                                                                                                    {"name": "body", "term": {"application": {"function": {"variable": "cons"}, "argument": {"variable": "t"}}}},
                                                                                                    {
                                                                                                      "name": "annotation",
                                                                                                      "term": {
                                                                                                        "application": {
                                                                                                          "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "annotation"}},
                                                                                                          "argument": {"variable": "at"}}}}]}}}}}}}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {"project": {"typeName": "hydra.core.model.AnnotatedTerm", "fieldName": "body"}},
                                                                                    "argument": {"variable": "at"}}}}}}}},
                                                                      {
                                                                        "name": "lambda",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.Lambda"},
                                                                            "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": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "domain"}}, "argument": {"variable": "l"}}}},
                                                                                        {
                                                                                          "name": "body",
                                                                                          "term": {
                                                                                            "application": {
                                                                                              "function": {
                                                                                                "application": {
                                                                                                  "function": {
                                                                                                    "application": {
                                                                                                      "function": {"variable": "digForLambdas"},
                                                                                                      "argument": {
                                                                                                        "application": {
                                                                                                          "function": {"variable": "cons"},
                                                                                                          "argument": {
                                                                                                            "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}},
                                                                                                  "argument": {
                                                                                                    "lambda": {
                                                                                                      "parameter": "t",
                                                                                                      "domain": {"variable": "hydra.core.model.Term"},
                                                                                                      "body": {"application": {"function": {"variable": "cons"}, "argument": {"variable": "t"}}}}}}},
                                                                                              "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": {"application": {"function": {"variable": "digForLambdas"}, "argument": {"variable": "original"}}},
                                                                                    "argument": {
                                                                                      "lambda": {
                                                                                        "parameter": "t",
                                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {"variable": "cons"},
                                                                                            "argument": {
                                                                                              "inject": {
                                                                                                "typeName": "hydra.core.model.Term",
                                                                                                "field": {
                                                                                                  "name": "let",
                                                                                                  "term": {
                                                                                                    "record": {
                                                                                                      "typeName": "hydra.core.model.Let",
                                                                                                      "fields": [
                                                                                                        {
                                                                                                          "name": "bindings",
                                                                                                          "term": {
                                                                                                            "application": {
                                                                                                              "function": {"variable": "rewriteBindings"},
                                                                                                              "argument": {
                                                                                                                "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "l"}}}}}},
                                                                                                        {"name": "body", "term": {"variable": "t"}}]}}}}}}}}}}},
                                                                                "argument": {
                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}}}]}},
                                                                "argument": {"variable": "term"}}}}}}}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {
                                                    "function": {
                                                      "domain": {"variable": "hydra.core.model.Term"},
                                                      "codomain": {
                                                        "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": {
                                                  "cases": {
                                                    "typeName": "hydra.core.model.Term",
                                                    "default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}},
                                                    "cases": [
                                                      {
                                                        "name": "let",
                                                        "handler": {
                                                          "lambda": {
                                                            "parameter": "l",
                                                            "domain": {"variable": "hydra.core.model.Let"},
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {"application": {"function": {"variable": "digForLambdas"}, "argument": {"variable": "term"}}},
                                                                    "argument": {
                                                                      "lambda": {
                                                                        "parameter": "t",
                                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                                        "body": {
                                                                          "inject": {
                                                                            "typeName": "hydra.core.model.Term",
                                                                            "field": {
                                                                              "name": "let",
                                                                              "term": {
                                                                                "record": {
                                                                                  "typeName": "hydra.core.model.Let",
                                                                                  "fields": [
                                                                                    {
                                                                                      "name": "bindings",
                                                                                      "term": {
                                                                                        "application": {
                                                                                          "function": {"variable": "rewriteBindings"},
                                                                                          "argument": {
                                                                                            "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "l"}}}}}},
                                                                                    {"name": "body", "term": {"variable": "t"}}]}}}}}}}}},
                                                                "argument": {
                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}}}]}},
                                                "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"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Rewrite terms like `let foo = bar in λx.baz` to `λx.let foo = bar in baz`, lifting lambda-bound variables above let-bound variables, recursively. This is helpful for targets such as Python."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.pruneLet",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Let"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Let"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "l",
                "domain": {"variable": "hydra.core.model.Let"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "bindingMap",
                        "term": {
                          "application": {
                            "function": {
                              "typeApplication": {
                                "body": {
                                  "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "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.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                        "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                    "argument": {
                                      "lambda": {
                                        "parameter": "b",
                                        "domain": {"variable": "hydra.core.model.Binding"},
                                        "body": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {
                                                "body": {
                                                  "pair": {
                                                    "first": {
                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}},
                                                    "second": {
                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}},
                                                "type": {"variable": "hydra.core.model.Name"}}},
                                            "type": {"variable": "hydra.core.model.Term"}}}}}}},
                                "argument": {
                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "l"}}}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
                          "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "rootName",
                            "term": {"wrap": {"typeName": "hydra.core.model.Name", "body": {"literal": {"string": "[[[root]]]"}}}},
                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "adj",
                                "term": {
                                  "lambda": {
                                    "parameter": "n",
                                    "domain": {"variable": "hydra.core.model.Name"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.sets.intersection"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "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.Term"}}},
                                                    "argument": {"variable": "bindingMap"}}}}}}},
                                        "argument": {
                                          "application": {
                                            "function": {"variable": "hydra.core.variables.freeVariablesInTerm"},
                                            "argument": {
                                              "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": "n"}}},
                                                            "argument": {"variable": "rootName"}}}}},
                                                    "argument": {
                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l"}}}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.withDefault"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                        "argument": {"inject": {"typeName": "hydra.core.model.Term", "field": {"name": "unit", "term": "unit"}}}}},
                                                    "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.Term"}}},
                                                            "argument": {"variable": "n"}}},
                                                        "argument": {"variable": "bindingMap"}}}}}}}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {
                                    "function": {"domain": {"variable": "hydra.core.model.Name"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}},
                                  "constraints": []}}],
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "reachable",
                                    "term": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.sorting.findReachableNodes"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {"variable": "adj"}}},
                                        "argument": {"variable": "rootName"}}},
                                    "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "prunedBindings",
                                        "term": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.filter"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                "argument": {
                                                  "lambda": {
                                                    "parameter": "b",
                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                    "body": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                            "argument": {
                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}}},
                                                        "argument": {"variable": "reachable"}}}}}}},
                                            "argument": {
                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "l"}}}}},
                                        "typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}}],
                                    "body": {
                                      "record": {
                                        "typeName": "hydra.core.model.Let",
                                        "fields": [
                                          {"name": "bindings", "term": {"variable": "prunedBindings"}},
                                          {
                                            "name": "body",
                                            "term": {
                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l"}}}}]}}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Given a let expression, remove any unused bindings. The resulting expression is still a let, even if has no remaining bindings"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.replaceTypedefs",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {
              "name": "arg0",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
              "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Type"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "types",
                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                "body": {
                  "lambda": {
                    "parameter": "typ0",
                    "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": "annotated",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "at",
                                                    "domain": {"variable": "hydra.core.model.AnnotatedType"},
                                                    "body": {
                                                      "inject": {
                                                        "typeName": "hydra.core.model.Type",
                                                        "field": {
                                                          "name": "annotated",
                                                          "term": {
                                                            "record": {
                                                              "typeName": "hydra.core.model.AnnotatedType",
                                                              "fields": [
                                                                {
                                                                  "name": "body",
                                                                  "term": {
                                                                    "application": {
                                                                      "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"variable": "recurse"}}},
                                                                      "argument": {
                                                                        "application": {
                                                                          "function": {"project": {"typeName": "hydra.core.model.AnnotatedType", "fieldName": "body"}},
                                                                          "argument": {"variable": "at"}}}}}},
                                                                {
                                                                  "name": "annotation",
                                                                  "term": {
                                                                    "application": {
                                                                      "function": {"project": {"typeName": "hydra.core.model.AnnotatedType", "fieldName": "annotation"}},
                                                                      "argument": {"variable": "at"}}}}]}}}}}}}},
                                              {
                                                "name": "record",
                                                "handler": {
                                                  "lambda": {"parameter": "_", "domain": {"list": {"variable": "hydra.core.model.FieldType"}}, "body": {"variable": "typ"}}}},
                                              {
                                                "name": "union",
                                                "handler": {
                                                  "lambda": {"parameter": "_", "domain": {"list": {"variable": "hydra.core.model.FieldType"}}, "body": {"variable": "typ"}}}},
                                              {
                                                "name": "variable",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "v",
                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "forMono",
                                                            "term": {
                                                              "lambda": {
                                                                "parameter": "t",
                                                                "domain": {"variable": "hydra.core.model.Type"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "cases": {
                                                                        "typeName": "hydra.core.model.Type",
                                                                        "default": {
                                                                          "application": {
                                                                            "function": {"application": {"function": {"variable": "rewrite"}, "argument": {"variable": "recurse"}}},
                                                                            "argument": {"variable": "t"}}},
                                                                        "cases": [
                                                                          {
                                                                            "name": "record",
                                                                            "handler": {
                                                                              "lambda": {"parameter": "_", "domain": {"list": {"variable": "hydra.core.model.FieldType"}}, "body": {"variable": "typ"}}}},
                                                                          {
                                                                            "name": "union",
                                                                            "handler": {
                                                                              "lambda": {"parameter": "_", "domain": {"list": {"variable": "hydra.core.model.FieldType"}}, "body": {"variable": "typ"}}}},
                                                                          {
                                                                            "name": "wrap",
                                                                            "handler": {"lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Type"}, "body": {"variable": "typ"}}}}]}},
                                                                    "argument": {"variable": "t"}}}}},
                                                            "typeScheme": {
                                                              "variables": [],
                                                              "body": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
                                                              "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "forTypeScheme",
                                                                "term": {
                                                                  "lambda": {
                                                                    "parameter": "ts",
                                                                    "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                    "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": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.isEmpty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
                                                                                            "argument": {"variable": "ts"}}}}}}},
                                                                                "argument": {"application": {"function": {"variable": "forMono"}, "argument": {"variable": "t"}}}}},
                                                                            "argument": {"variable": "typ"}}}}}}},
                                                                "typeScheme": {
                                                                  "variables": [],
                                                                  "body": {"function": {"domain": {"variable": "hydra.core.model.TypeScheme"}, "codomain": {"variable": "hydra.core.model.Type"}}},
                                                                  "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": {"variable": "hydra.core.model.Type"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {
                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                "argument": {"variable": "v"}}},
                                                                            "argument": {"variable": "types"}}}}},
                                                                    "argument": {"variable": "typ"}}},
                                                                "argument": {
                                                                  "lambda": {
                                                                    "parameter": "ts",
                                                                    "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                    "body": {"application": {"function": {"variable": "forTypeScheme"}, "argument": {"variable": "ts"}}}}}}}}}}}}}},
                                              {
                                                "name": "wrap",
                                                "handler": {"lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Type"}, "body": {"variable": "typ"}}}}]}},
                                        "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": "typ0"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Replace all occurrences of simple typedefs (type aliases) with the aliased types, recursively"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.simplifyTerm",
        "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": "simplify",
                        "term": {
                          "typeLambda": {
                            "parameter": "t0",
                            "body": {
                              "lambda": {
                                "parameter": "recurse",
                                "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "t0"}}},
                                "body": {
                                  "lambda": {
                                    "parameter": "term",
                                    "domain": {"variable": "hydra.core.model.Term"},
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "forRhs",
                                            "term": {
                                              "lambda": {
                                                "parameter": "rhs",
                                                "domain": {"variable": "hydra.core.model.Term"},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "var",
                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "body",
                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "cases": {
                                                                "typeName": "hydra.core.model.Term",
                                                                "default": {"variable": "term"},
                                                                "cases": [
                                                                  {
                                                                    "name": "variable",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "v",
                                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {"variable": "hydra.core.dependencies.simplifyTerm"},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {"application": {"function": {"variable": "hydra.core.variables.substituteVariable"}, "argument": {"variable": "var"}}},
                                                                                    "argument": {"variable": "v"}}},
                                                                                "argument": {"variable": "body"}}}}}}}}]}},
                                                            "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "rhs"}}}}}}}}}}},
                                            "typeScheme": {
                                              "variables": [],
                                              "body": {
                                                "function": {
                                                  "domain": {"variable": "hydra.core.model.Term"},
                                                  "codomain": {
                                                    "function": {
                                                      "domain": {"variable": "hydra.core.model.Name"},
                                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}}}},
                                              "constraints": []}}],
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "forLhs",
                                                "term": {
                                                  "lambda": {
                                                    "parameter": "lhs",
                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "rhs",
                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "cases": {
                                                                "typeName": "hydra.core.model.Term",
                                                                "default": {"variable": "term"},
                                                                "cases": [
                                                                  {
                                                                    "name": "lambda",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "l",
                                                                        "domain": {"variable": "hydra.core.model.Lambda"},
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "var",
                                                                                "term": {
                                                                                  "application": {
                                                                                    "function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
                                                                                    "argument": {"variable": "l"}}},
                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "body",
                                                                                    "term": {
                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}},
                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "argument": {"variable": "var"}}},
                                                                                                "argument": {
                                                                                                  "application": {"function": {"variable": "hydra.core.variables.freeVariablesInTerm"}, "argument": {"variable": "body"}}}}}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "forRhs"}, "argument": {"variable": "rhs"}}},
                                                                                                "argument": {"variable": "var"}}},
                                                                                            "argument": {"variable": "body"}}}}},
                                                                                    "argument": {"application": {"function": {"variable": "hydra.core.dependencies.simplifyTerm"}, "argument": {"variable": "body"}}}}}}}}}}}}]}},
                                                            "argument": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "lhs"}}}}}}}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {
                                                    "function": {
                                                      "domain": {"variable": "hydra.core.model.Term"},
                                                      "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "forTerm",
                                                    "term": {
                                                      "lambda": {
                                                        "parameter": "stripped",
                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "cases": {
                                                                "typeName": "hydra.core.model.Term",
                                                                "default": {"variable": "term"},
                                                                "cases": [
                                                                  {
                                                                    "name": "application",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "app",
                                                                        "domain": {"variable": "hydra.core.model.Application"},
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "lhs",
                                                                                "term": {
                                                                                  "application": {
                                                                                    "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "function"}},
                                                                                    "argument": {"variable": "app"}}},
                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "rhs",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {"project": {"typeName": "hydra.core.model.Application", "fieldName": "argument"}},
                                                                                        "argument": {"variable": "app"}}},
                                                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {"application": {"function": {"variable": "forLhs"}, "argument": {"variable": "lhs"}}},
                                                                                    "argument": {"variable": "rhs"}}}}}}}}}}]}},
                                                            "argument": {"variable": "stripped"}}}}},
                                                    "typeScheme": {
                                                      "variables": [],
                                                      "body": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
                                                      "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "stripped",
                                                        "term": {"application": {"function": {"variable": "hydra.core.strip.deannotateTerm"}, "argument": {"variable": "term"}}},
                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                    "body": {
                                                      "application": {
                                                        "function": {"variable": "recurse"},
                                                        "argument": {"application": {"function": {"variable": "forTerm"}, "argument": {"variable": "stripped"}}}}}}}}}}}}}}}}}}},
                        "typeScheme": {
                          "variables": ["t0"],
                          "body": {
                            "function": {
                              "domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "t0"}}},
                              "codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "t0"}}}}},
                          "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {"variable": "hydra.core.rewriting.rewriteTerm"},
                            "argument": {"typeApplication": {"body": {"variable": "simplify"}, "type": {"variable": "hydra.core.model.Term"}}}}},
                        "argument": {"variable": "term"}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Simplify terms by applying beta reduction where possible"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.termDependencyNames",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"literal": "boolean"}, "isLazy": false},
            {"name": "arg1", "type": {"literal": "boolean"}, "isLazy": false},
            {"name": "arg2", "type": {"literal": "boolean"}, "isLazy": false},
            {"name": "arg3", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "binds",
                "domain": {"literal": "boolean"},
                "body": {
                  "lambda": {
                    "parameter": "withPrims",
                    "domain": {"literal": "boolean"},
                    "body": {
                      "lambda": {
                        "parameter": "withNoms",
                        "domain": {"literal": "boolean"},
                        "body": {
                          "lambda": {
                            "parameter": "term0",
                            "domain": {"variable": "hydra.core.model.Term"},
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "addNames",
                                    "term": {
                                      "lambda": {
                                        "parameter": "names",
                                        "domain": {"set": {"variable": "hydra.core.model.Name"}},
                                        "body": {
                                          "lambda": {
                                            "parameter": "term",
                                            "domain": {"variable": "hydra.core.model.Term"},
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "nominal",
                                                    "term": {
                                                      "lambda": {
                                                        "parameter": "name",
                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                    "argument": {"variable": "withNoms"}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                        "argument": {"variable": "name"}}},
                                                                    "argument": {"variable": "names"}}}}},
                                                            "argument": {"variable": "names"}}}}},
                                                    "typeScheme": {
                                                      "variables": [],
                                                      "body": {
                                                        "function": {"domain": {"variable": "hydra.core.model.Name"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                      "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "prim",
                                                        "term": {
                                                          "lambda": {
                                                            "parameter": "name",
                                                            "domain": {"variable": "hydra.core.model.Name"},
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                        "argument": {"variable": "withPrims"}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "argument": {"variable": "name"}}},
                                                                        "argument": {"variable": "names"}}}}},
                                                                "argument": {"variable": "names"}}}}},
                                                        "typeScheme": {
                                                          "variables": [],
                                                          "body": {
                                                            "function": {"domain": {"variable": "hydra.core.model.Name"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                          "constraints": []}}],
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "var",
                                                            "term": {
                                                              "lambda": {
                                                                "parameter": "name",
                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                                            "argument": {"variable": "binds"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                "argument": {"variable": "name"}}},
                                                                            "argument": {"variable": "names"}}}}},
                                                                    "argument": {"variable": "names"}}}}},
                                                            "typeScheme": {
                                                              "variables": [],
                                                              "body": {
                                                                "function": {"domain": {"variable": "hydra.core.model.Name"}, "codomain": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                              "constraints": []}}],
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "cases": {
                                                                "typeName": "hydra.core.model.Term",
                                                                "default": {"variable": "names"},
                                                                "cases": [
                                                                  {
                                                                    "name": "cases",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "caseStmt",
                                                                        "domain": {"variable": "hydra.core.model.CaseStatement"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {"variable": "nominal"},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.CaseStatement", "fieldName": "typeName"}},
                                                                                "argument": {"variable": "caseStmt"}}}}}}}},
                                                                  {
                                                                    "name": "project",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "proj",
                                                                        "domain": {"variable": "hydra.core.model.Projection"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {"variable": "nominal"},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.Projection", "fieldName": "typeName"}},
                                                                                "argument": {"variable": "proj"}}}}}}}},
                                                                  {
                                                                    "name": "unwrap",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "name",
                                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                                        "body": {"application": {"function": {"variable": "nominal"}, "argument": {"variable": "name"}}}}}},
                                                                  {
                                                                    "name": "record",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "record",
                                                                        "domain": {"variable": "hydra.core.model.Record"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {"variable": "nominal"},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.Record", "fieldName": "typeName"}},
                                                                                "argument": {"variable": "record"}}}}}}}},
                                                                  {
                                                                    "name": "inject",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "injection",
                                                                        "domain": {"variable": "hydra.core.model.Injection"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {"variable": "nominal"},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.Injection", "fieldName": "typeName"}},
                                                                                "argument": {"variable": "injection"}}}}}}}},
                                                                  {
                                                                    "name": "variable",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "name",
                                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                                        "body": {"application": {"function": {"variable": "var"}, "argument": {"variable": "name"}}}}}},
                                                                  {
                                                                    "name": "wrap",
                                                                    "handler": {
                                                                      "lambda": {
                                                                        "parameter": "wrappedTerm",
                                                                        "domain": {"variable": "hydra.core.model.WrappedTerm"},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {"variable": "nominal"},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.WrappedTerm", "fieldName": "typeName"}},
                                                                                "argument": {"variable": "wrappedTerm"}}}}}}}}]}},
                                                            "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": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.rewriting.foldOverTerm"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                "argument": {"inject": {"typeName": "hydra.core.coders.TraversalOrder", "field": {"name": "pre", "term": "unit"}}}}},
                                            "argument": {"variable": "addNames"}}},
                                        "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": "Note: does not distinguish between bound and free variables; use freeVariablesInTerm for that"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.toShortNames",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"list": {"variable": "hydra.core.model.Name"}}, "isLazy": false}],
          "result": {"type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Name"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "original",
                "domain": {"list": {"variable": "hydra.core.model.Name"}},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "addName",
                        "term": {
                          "lambda": {
                            "parameter": "acc",
                            "domain": {"map": {"keys": {"literal": "string"}, "values": {"set": {"variable": "hydra.core.model.Name"}}}},
                            "body": {
                              "lambda": {
                                "parameter": "name",
                                "domain": {"variable": "hydra.core.model.Name"},
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "local",
                                        "term": {"application": {"function": {"variable": "hydra.core.names.localNameOf"}, "argument": {"variable": "name"}}},
                                        "typeScheme": {"variables": [], "body": {"literal": "string"}, "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "group",
                                            "term": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.withDefault"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                    "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"literal": "string"}}},
                                                            "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                        "argument": {"variable": "local"}}},
                                                    "argument": {"variable": "acc"}}}}},
                                            "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                                        "body": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"literal": "string"}}},
                                                        "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                    "argument": {"variable": "local"}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.insert"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "argument": {"variable": "name"}}},
                                                    "argument": {"variable": "group"}}}}},
                                            "argument": {"variable": "acc"}}}}}}}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {
                            "function": {
                              "domain": {"map": {"keys": {"literal": "string"}, "values": {"set": {"variable": "hydra.core.model.Name"}}}},
                              "codomain": {
                                "function": {
                                  "domain": {"variable": "hydra.core.model.Name"},
                                  "codomain": {"map": {"keys": {"literal": "string"}, "values": {"set": {"variable": "hydra.core.model.Name"}}}}}}}},
                          "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "groupNamesByLocal",
                            "term": {
                              "lambda": {
                                "parameter": "names",
                                "domain": {"list": {"variable": "hydra.core.model.Name"}},
                                "body": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {"variable": "hydra.core.lib.lists.foldl"},
                                                    "type": {"map": {"keys": {"literal": "string"}, "values": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {"variable": "addName"}}},
                                        "argument": {
                                          "typeApplication": {
                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"literal": "string"}}},
                                            "type": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                    "argument": {"variable": "names"}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {
                                  "domain": {"list": {"variable": "hydra.core.model.Name"}},
                                  "codomain": {"map": {"keys": {"literal": "string"}, "values": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                              "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "groups",
                                "term": {"application": {"function": {"variable": "groupNamesByLocal"}, "argument": {"variable": "original"}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {"map": {"keys": {"literal": "string"}, "values": {"set": {"variable": "hydra.core.model.Name"}}}},
                                  "constraints": []}}],
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "renameGroup",
                                    "term": {
                                      "typeLambda": {
                                        "parameter": "t0",
                                        "body": {
                                          "lambda": {
                                            "parameter": "localNames",
                                            "domain": {"pair": {"first": {"literal": "string"}, "second": {"set": {"variable": "t0"}}}},
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "local",
                                                    "term": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"literal": "string"}}},
                                                            "type": {"set": {"variable": "t0"}}}},
                                                        "argument": {"variable": "localNames"}}},
                                                    "typeScheme": {"variables": [], "body": {"literal": "string"}, "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "names",
                                                        "term": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"literal": "string"}}},
                                                                "type": {"set": {"variable": "t0"}}}},
                                                            "argument": {"variable": "localNames"}}},
                                                        "typeScheme": {"variables": [], "body": {"set": {"variable": "t0"}}, "constraints": []}}],
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "rangeFrom",
                                                            "term": {
                                                              "lambda": {
                                                                "parameter": "start",
                                                                "domain": {"literal": {"integer": "int32"}},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"literal": {"integer": "int32"}}}},
                                                                        "argument": {"variable": "start"}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {"variable": "rangeFrom"},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.add"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                "argument": {"variable": "start"}}},
                                                                            "argument": {"literal": {"integer": {"int32": 1}}}}}}}}}}},
                                                            "typeScheme": {
                                                              "variables": [],
                                                              "body": {"function": {"domain": {"literal": {"integer": "int32"}}, "codomain": {"list": {"literal": {"integer": "int32"}}}}},
                                                              "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "rename",
                                                                "term": {
                                                                  "typeLambda": {
                                                                    "parameter": "t1",
                                                                    "body": {
                                                                      "lambda": {
                                                                        "parameter": "name",
                                                                        "domain": {"variable": "t1"},
                                                                        "body": {
                                                                          "lambda": {
                                                                            "parameter": "i",
                                                                            "domain": {"literal": {"integer": "int32"}},
                                                                            "body": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "pair": {
                                                                                        "first": {"variable": "name"},
                                                                                        "second": {
                                                                                          "wrap": {
                                                                                            "typeName": "hydra.core.model.Name",
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"literal": "string"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.gt"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                                "argument": {"variable": "i"}}},
                                                                                                            "argument": {"literal": {"integer": {"int32": 1}}}}}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"variable": "local"}}},
                                                                                                        "argument": {"application": {"function": {"variable": "hydra.core.lib.literals.printInt32"}, "argument": {"variable": "i"}}}}}}},
                                                                                                "argument": {"variable": "local"}}}}}}},
                                                                                    "type": {"variable": "t1"}}},
                                                                                "type": {"variable": "hydra.core.model.Name"}}}}}}}}},
                                                                "typeScheme": {
                                                                  "variables": ["t1"],
                                                                  "body": {
                                                                    "function": {
                                                                      "domain": {"variable": "t1"},
                                                                      "codomain": {
                                                                        "function": {
                                                                          "domain": {"literal": {"integer": "int32"}},
                                                                          "codomain": {"pair": {"first": {"variable": "t1"}, "second": {"variable": "hydra.core.model.Name"}}}}}}},
                                                                  "constraints": []}}],
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {
                                                                              "typeApplication": {
                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.zipWith"}, "type": {"variable": "t0"}}},
                                                                                "type": {"literal": {"integer": "int32"}}}},
                                                                            "type": {"pair": {"first": {"variable": "t0"}, "second": {"variable": "hydra.core.model.Name"}}}}},
                                                                        "argument": {"typeApplication": {"body": {"variable": "rename"}, "type": {"variable": "t0"}}}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.toList"}, "type": {"variable": "t0"}}},
                                                                        "argument": {"variable": "names"}}}}},
                                                                "argument": {"application": {"function": {"variable": "rangeFrom"}, "argument": {"literal": {"integer": {"int32": 1}}}}}}}}}}}}}}}}}}},
                                    "typeScheme": {
                                      "variables": ["t0"],
                                      "body": {
                                        "function": {
                                          "domain": {"pair": {"first": {"literal": "string"}, "second": {"set": {"variable": "t0"}}}},
                                          "codomain": {"list": {"pair": {"first": {"variable": "t0"}, "second": {"variable": "hydra.core.model.Name"}}}}}},
                                      "constraints": [{"key": "t0", "value": {"classes": [{"simple": "ordering"}]}}]}}],
                                "body": {
                                  "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": {
                                          "typeApplication": {
                                            "body": {"variable": "hydra.core.lib.lists.concat"},
                                            "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Name"}}}}},
                                        "argument": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {
                                                        "body": {"variable": "hydra.core.lib.lists.map"},
                                                        "type": {"pair": {"first": {"literal": "string"}, "second": {"set": {"variable": "hydra.core.model.Name"}}}}}},
                                                    "type": {"list": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Name"}}}}}},
                                                "argument": {"typeApplication": {"body": {"variable": "renameGroup"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.toList"}, "type": {"literal": "string"}}},
                                                    "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                                "argument": {"variable": "groups"}}}}}}}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Generate short names from a list of fully qualified names"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.topologicalSortBindingMap",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {
              "name": "arg0",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
              "isLazy": false}],
          "result": {
            "type": {
              "list": {"list": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "bindingMap",
                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "bindings",
                        "term": {
                          "application": {
                            "function": {
                              "typeApplication": {
                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                "type": {"variable": "hydra.core.model.Term"}}},
                            "argument": {"variable": "bindingMap"}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {"list": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}},
                          "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "keys",
                            "term": {
                              "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": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                            "type": {"variable": "hydra.core.model.Name"}}},
                                        "argument": {
                                          "typeApplication": {
                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "type": {"variable": "hydra.core.model.Term"}}}}},
                                    "argument": {"variable": "bindings"}}}}},
                            "typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "hasTypeAnnotation",
                                "term": {
                                  "lambda": {
                                    "parameter": "term",
                                    "domain": {"variable": "hydra.core.model.Term"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.isGiven"}, "type": {"variable": "hydra.core.model.Term"}}},
                                        "argument": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {"variable": "hydra.core.annotations.getTermAnnotation"},
                                                "argument": {"variable": "hydra.core.constants.keyType"}}},
                                            "argument": {"variable": "term"}}}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"literal": "boolean"}}},
                                  "constraints": []}}],
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "depsOf",
                                    "term": {
                                      "typeLambda": {
                                        "parameter": "t0",
                                        "body": {
                                          "lambda": {
                                            "parameter": "nameAndTerm",
                                            "domain": {"pair": {"first": {"variable": "t0"}, "second": {"variable": "hydra.core.model.Term"}}},
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "name",
                                                    "term": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "t0"}}},
                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                        "argument": {"variable": "nameAndTerm"}}},
                                                    "typeScheme": {"variables": [], "body": {"variable": "t0"}, "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "term",
                                                        "term": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "t0"}}},
                                                                "type": {"variable": "hydra.core.model.Term"}}},
                                                            "argument": {"variable": "nameAndTerm"}}},
                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                    "body": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "pair": {
                                                                "first": {"variable": "name"},
                                                                "second": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                                            "argument": {"application": {"function": {"variable": "hasTypeAnnotation"}, "argument": {"variable": "term"}}}}},
                                                                        "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                                    "argument": {
                                                                      "application": {
                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.sets.intersection"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                "argument": {"variable": "keys"}}},
                                                                            "argument": {
                                                                              "application": {"function": {"variable": "hydra.core.variables.freeVariablesInTerm"}, "argument": {"variable": "term"}}}}}}}}}}},
                                                            "type": {"variable": "t0"}}},
                                                        "type": {"list": {"variable": "hydra.core.model.Name"}}}}}}}}}}}},
                                    "typeScheme": {
                                      "variables": ["t0"],
                                      "body": {
                                        "function": {
                                          "domain": {"pair": {"first": {"variable": "t0"}, "second": {"variable": "hydra.core.model.Term"}}},
                                          "codomain": {"pair": {"first": {"variable": "t0"}, "second": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                                      "constraints": [{"key": "t0", "value": {"classes": []}}]}}],
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "toPair",
                                        "term": {
                                          "lambda": {
                                            "parameter": "name",
                                            "domain": {"variable": "hydra.core.model.Name"},
                                            "body": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "pair": {
                                                        "first": {"variable": "name"},
                                                        "second": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.withDefault"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                "argument": {
                                                                  "inject": {
                                                                    "typeName": "hydra.core.model.Term",
                                                                    "field": {
                                                                      "name": "literal",
                                                                      "term": {
                                                                        "inject": {"typeName": "hydra.core.model.Literal", "field": {"name": "string", "term": {"literal": {"string": "Impossible!"}}}}}}}}}},
                                                            "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.Term"}}},
                                                                    "argument": {"variable": "name"}}},
                                                                "argument": {"variable": "bindingMap"}}}}}}},
                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                "type": {"variable": "hydra.core.model.Term"}}}}},
                                        "typeScheme": {
                                          "variables": [],
                                          "body": {
                                            "function": {
                                              "domain": {"variable": "hydra.core.model.Name"},
                                              "codomain": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                          "constraints": []}}],
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                                "type": {"list": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                    "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                                "argument": {"variable": "toPair"}}}}},
                                        "argument": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.sorting.topologicalSortComponents"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "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": "hydra.core.model.Term"}}}}},
                                                        "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                                                    "argument": {"typeApplication": {"body": {"variable": "depsOf"}, "type": {"variable": "hydra.core.model.Name"}}}}},
                                                "argument": {"variable": "bindings"}}}}}}}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Topological sort of connected components, in terms of dependencies between variable/term binding pairs. The SCC partitioning is what makes the result usable as an emission order in every target language: non-recursive bindings emit in dependency order, while a mutually recursive cluster is delivered together so the emitter can wrap it in whatever construct the host requires (mutual `let`s, joint class files, forward declarations)."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.topologicalSortBindings",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"list": {"variable": "hydra.core.model.Binding"}}, "isLazy": false}],
          "result": {
            "type": {
              "either": {
                "left": {"list": {"list": {"variable": "hydra.core.model.Name"}}},
                "right": {"list": {"variable": "hydra.core.model.Name"}}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "els",
                "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "adjlist",
                        "term": {
                          "lambda": {
                            "parameter": "e",
                            "domain": {"variable": "hydra.core.model.Binding"},
                            "body": {
                              "typeApplication": {
                                "body": {
                                  "typeApplication": {
                                    "body": {
                                      "pair": {
                                        "first": {
                                          "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "e"}}},
                                        "second": {
                                          "application": {
                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "application": {"function": {"variable": "hydra.core.dependencies.termDependencyNames"}, "argument": {"literal": {"boolean": false}}}},
                                                        "argument": {"literal": {"boolean": true}}}},
                                                    "argument": {"literal": {"boolean": true}}}},
                                                "argument": {
                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "e"}}}}}}}}},
                                    "type": {"variable": "hydra.core.model.Name"}}},
                                "type": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {
                            "function": {
                              "domain": {"variable": "hydra.core.model.Binding"},
                              "codomain": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                          "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "typeApplication": {"body": {"variable": "hydra.core.sorting.topologicalSort"}, "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": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                                "argument": {"variable": "adjlist"}}},
                            "argument": {"variable": "els"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Topological sort of bindings based on their dependencies. Returns `Right` with a flat order when the dependency graph is acyclic; returns `Left` with the cyclic SCCs when it is not. Use this variant when the consumer needs a strict acyclic ordering and must reject cycles (e.g. import resolution); use `topologicalSortBindingMap` when mutual recursion should be packaged into SCC groups instead."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.topologicalSortTypeDefinitions",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"list": {"variable": "hydra.core.packaging.TypeDefinition"}}, "isLazy": false}],
          "result": {"type": {"list": {"list": {"variable": "hydra.core.packaging.TypeDefinition"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "defs",
                "domain": {"list": {"variable": "hydra.core.packaging.TypeDefinition"}},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "toPair",
                        "term": {
                          "lambda": {
                            "parameter": "def",
                            "domain": {"variable": "hydra.core.packaging.TypeDefinition"},
                            "body": {
                              "typeApplication": {
                                "body": {
                                  "typeApplication": {
                                    "body": {
                                      "pair": {
                                        "first": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.packaging.TypeDefinition", "fieldName": "name"}},
                                            "argument": {"variable": "def"}}},
                                        "second": {
                                          "application": {
                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {"function": {"variable": "hydra.core.dependencies.typeDependencyNames"}, "argument": {"literal": {"boolean": false}}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.packaging.TypeDefinition", "fieldName": "body"}},
                                                        "argument": {"variable": "def"}}}}}}}}}}},
                                    "type": {"variable": "hydra.core.model.Name"}}},
                                "type": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                        "typeScheme": {
                          "variables": [],
                          "body": {
                            "function": {
                              "domain": {"variable": "hydra.core.packaging.TypeDefinition"},
                              "codomain": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                          "constraints": []}}],
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "nameToDef",
                            "term": {
                              "application": {
                                "function": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                    "type": {"variable": "hydra.core.packaging.TypeDefinition"}}},
                                "argument": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.packaging.TypeDefinition"}}},
                                            "type": {
                                              "pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.packaging.TypeDefinition"}}}}},
                                        "argument": {
                                          "lambda": {
                                            "parameter": "d",
                                            "domain": {"variable": "hydra.core.packaging.TypeDefinition"},
                                            "body": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "pair": {
                                                        "first": {
                                                          "application": {
                                                            "function": {"project": {"typeName": "hydra.core.packaging.TypeDefinition", "fieldName": "name"}},
                                                            "argument": {"variable": "d"}}},
                                                        "second": {"variable": "d"}}},
                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                "type": {"variable": "hydra.core.packaging.TypeDefinition"}}}}}}},
                                    "argument": {"variable": "defs"}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.packaging.TypeDefinition"}}},
                              "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "sorted",
                                "term": {
                                  "application": {
                                    "function": {
                                      "typeApplication": {"body": {"variable": "hydra.core.sorting.topologicalSortComponents"}, "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.packaging.TypeDefinition"}}},
                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"list": {"variable": "hydra.core.model.Name"}}}}}},
                                            "argument": {"variable": "toPair"}}},
                                        "argument": {"variable": "defs"}}}}},
                                "typeScheme": {"variables": [], "body": {"list": {"list": {"variable": "hydra.core.model.Name"}}}, "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "typeApplication": {
                                        "body": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"list": {"variable": "hydra.core.model.Name"}}}},
                                        "type": {"list": {"variable": "hydra.core.packaging.TypeDefinition"}}}},
                                    "argument": {
                                      "lambda": {
                                        "parameter": "names",
                                        "domain": {"list": {"variable": "hydra.core.model.Name"}},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.givens"}, "type": {"variable": "hydra.core.packaging.TypeDefinition"}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "type": {"optional": {"variable": "hydra.core.packaging.TypeDefinition"}}}},
                                                    "argument": {
                                                      "lambda": {
                                                        "parameter": "n",
                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                    "type": {"variable": "hydra.core.packaging.TypeDefinition"}}},
                                                                "argument": {"variable": "n"}}},
                                                            "argument": {"variable": "nameToDef"}}}}}}},
                                                "argument": {"variable": "names"}}}}}}}}},
                                "argument": {"variable": "sorted"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Topologically sort type definitions by their structural dependencies, grouped into SCCs. The SCC grouping handles mutually recursive types (e.g. a pair of records that reference each other's names) by delivering them together as one cluster, so the emitter can produce a coherent set of declarations rather than failing with an undefined-name error mid-emission."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.typeDependencyNames",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"literal": "boolean"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "hydra.core.model.Name"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "withSchema",
                "domain": {"literal": "boolean"},
                "body": {
                  "lambda": {
                    "parameter": "typ",
                    "domain": {"variable": "hydra.core.model.Type"},
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"set": {"variable": "hydra.core.model.Name"}}}},
                                "argument": {"variable": "withSchema"}}},
                            "argument": {
                              "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.freeVariablesInType"}, "argument": {"variable": "typ"}}}}},
                                "argument": {
                                  "application": {
                                    "function": {
                                      "typeApplication": {"body": {"variable": "hydra.core.dependencies.typeNamesInType"}, "type": {"variable": "hydra.core.model.Name"}}},
                                    "argument": {"variable": "typ"}}}}}}},
                        "argument": {"application": {"function": {"variable": "hydra.core.variables.freeVariablesInType"}, "argument": {"variable": "typ"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Collect all type names referenced by a type. The boolean controls whether type-scheme references (free variables in type expressions) are included alongside structural references"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.dependencies.typeNamesInType",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": [{"simple": "ordering"}]}],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"set": {"variable": "t0"}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "typ0",
                    "domain": {"variable": "hydra.core.model.Type"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "addNames",
                            "term": {
                              "typeLambda": {
                                "parameter": "t1",
                                "body": {
                                  "typeLambda": {
                                    "parameter": "t2",
                                    "body": {
                                      "lambda": {
                                        "parameter": "names",
                                        "domain": {"variable": "t1"},
                                        "body": {"lambda": {"parameter": "typ", "domain": {"variable": "t2"}, "body": {"variable": "names"}}}}}}}}},
                            "typeScheme": {
                              "variables": ["t1", "t2"],
                              "body": {
                                "function": {"domain": {"variable": "t1"}, "codomain": {"function": {"domain": {"variable": "t2"}, "codomain": {"variable": "t1"}}}}},
                              "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.rewriting.foldOverType"}, "type": {"set": {"variable": "t0"}}}},
                                        "argument": {"inject": {"typeName": "hydra.core.coders.TraversalOrder", "field": {"name": "pre", "term": "unit"}}}}},
                                    "argument": {
                                      "typeApplication": {
                                        "body": {"typeApplication": {"body": {"variable": "addNames"}, "type": {"set": {"variable": "t0"}}}},
                                        "type": {"variable": "hydra.core.model.Type"}}}}},
                                "argument": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "t0"}}}}},
                            "argument": {"variable": "typ0"}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {"literal": {"string": "Collect every type name that appears anywhere inside a type expression"}}}]}}}}}}}]}