packages feed

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

{
  "name": "hydra.core.lexical",
  "metadata": {"description": "A module for lexical operations over graphs.", "comments": [], "seeAlso": [], "provisions": []},
  "dependencies": [
    {"module": "hydra.core.errors"},
    {"module": "hydra.core.graph"},
    {"module": "hydra.core.lib.eithers"},
    {"module": "hydra.core.lib.equality"},
    {"module": "hydra.core.lib.lists"},
    {"module": "hydra.core.lib.literals"},
    {"module": "hydra.core.lib.logic"},
    {"module": "hydra.core.lib.maps"},
    {"module": "hydra.core.lib.math"},
    {"module": "hydra.core.lib.optionals"},
    {"module": "hydra.core.lib.ordering"},
    {"module": "hydra.core.lib.pairs"},
    {"module": "hydra.core.lib.sets"},
    {"module": "hydra.core.lib.strings"},
    {"module": "hydra.core.model"},
    {"module": "hydra.core.packaging"},
    {"module": "hydra.core.print.model"},
    {"module": "hydra.core.scoping"},
    {"module": "hydra.core.strip"},
    {"module": "hydra.core.typing"}],
  "definitions": [
    {
      "term": {
        "name": "hydra.core.lexical.buildGraph",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"list": {"variable": "hydra.core.model.Binding"}}, "isLazy": false},
            {
              "name": "arg1",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"optional": {"variable": "hydra.core.model.Term"}}}},
              "isLazy": false},
            {
              "name": "arg2",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.graph.Primitive"}}},
              "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.graph.Graph"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "elements",
                "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                "body": {
                  "lambda": {
                    "parameter": "environment",
                    "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"optional": {"variable": "hydra.core.model.Term"}}}},
                    "body": {
                      "lambda": {
                        "parameter": "primitives",
                        "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.graph.Primitive"}}},
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "elementTerms",
                                "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": {"variable": "elements"}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
                                  "constraints": []}}],
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "letTerms",
                                    "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.optionals.mapOptional"},
                                                        "type": {
                                                          "pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"optional": {"variable": "hydra.core.model.Term"}}}}}},
                                                    "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                                "argument": {
                                                  "lambda": {
                                                    "parameter": "kv",
                                                    "domain": {
                                                      "pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"optional": {"variable": "hydra.core.model.Term"}}}},
                                                    "body": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                                            "argument": {
                                                              "lambda": {
                                                                "parameter": "t",
                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                "body": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {
                                                                        "body": {
                                                                          "pair": {
                                                                            "first": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {
                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "type": {"optional": {"variable": "hydra.core.model.Term"}}}},
                                                                                "argument": {"variable": "kv"}}},
                                                                            "second": {"variable": "t"}}},
                                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                                    "type": {"variable": "hydra.core.model.Term"}}}}}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                "type": {"optional": {"variable": "hydra.core.model.Term"}}}},
                                                            "argument": {"variable": "kv"}}}}}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                    "type": {"optional": {"variable": "hydra.core.model.Term"}}}},
                                                "argument": {"variable": "environment"}}}}}}},
                                    "typeScheme": {
                                      "variables": [],
                                      "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
                                      "constraints": []}}],
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "mergedTerms",
                                        "term": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                "argument": {"variable": "elementTerms"}}},
                                            "argument": {"variable": "letTerms"}}},
                                        "typeScheme": {
                                          "variables": [],
                                          "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
                                          "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "filteredTerms",
                                            "term": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.maps.filterWithKey"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                    "argument": {
                                                      "lambda": {
                                                        "parameter": "k",
                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                        "body": {
                                                          "lambda": {
                                                            "parameter": "_v",
                                                            "domain": {"variable": "hydra.core.model.Term"},
                                                            "body": {
                                                              "application": {
                                                                "function": {"variable": "hydra.core.lib.logic.not"},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "type": {"variable": "hydra.core.graph.Primitive"}}},
                                                                        "argument": {"variable": "k"}}},
                                                                    "argument": {"variable": "primitives"}}}}}}}}}}},
                                                "argument": {"variable": "mergedTerms"}}},
                                            "typeScheme": {
                                              "variables": [],
                                              "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
                                              "constraints": []}}],
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "elementTypes",
                                                "term": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {"variable": "hydra.core.lib.optionals.givens"},
                                                            "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.TypeScheme"}}}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                                    "type": {
                                                                      "optional": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.TypeScheme"}}}}}},
                                                                "argument": {
                                                                  "lambda": {
                                                                    "parameter": "b",
                                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.TypeScheme"}}}}},
                                                                            "argument": {
                                                                              "lambda": {
                                                                                "parameter": "ts",
                                                                                "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                                "body": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "pair": {
                                                                                            "first": {
                                                                                              "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}},
                                                                                            "second": {"variable": "ts"}}},
                                                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "type": {"variable": "hydra.core.model.TypeScheme"}}}}}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
                                                                            "argument": {"variable": "b"}}}}}}}}},
                                                            "argument": {"variable": "elements"}}}}}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "filteredTypes",
                                                    "term": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.maps.filterWithKey"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                            "argument": {
                                                              "lambda": {
                                                                "parameter": "k",
                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                "body": {
                                                                  "lambda": {
                                                                    "parameter": "_v",
                                                                    "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {"variable": "hydra.core.lib.logic.not"},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {
                                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                    "type": {"variable": "hydra.core.graph.Primitive"}}},
                                                                                "argument": {"variable": "k"}}},
                                                                            "argument": {"variable": "primitives"}}}}}}}}}}},
                                                        "argument": {"variable": "elementTypes"}}},
                                                    "typeScheme": {
                                                      "variables": [],
                                                      "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                                                      "constraints": []}}],
                                                "body": {
                                                  "record": {
                                                    "typeName": "hydra.core.graph.Graph",
                                                    "fields": [
                                                      {"name": "boundTerms", "term": {"variable": "filteredTerms"}},
                                                      {"name": "boundTypes", "term": {"variable": "filteredTypes"}},
                                                      {
                                                        "name": "classConstraints",
                                                        "term": {
                                                          "typeApplication": {
                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                            "type": {"variable": "hydra.core.model.TypeVariableConstraints"}}}},
                                                      {
                                                        "name": "lambdaVariables",
                                                        "term": {
                                                          "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": {"optional": {"variable": "hydra.core.model.Term"}}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {
                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.maps.filter"}, "type": {"optional": {"variable": "hydra.core.model.Term"}}}},
                                                                            "type": {"variable": "hydra.core.model.Name"}}},
                                                                        "argument": {
                                                                          "lambda": {
                                                                            "parameter": "mt",
                                                                            "domain": {"optional": {"variable": "hydra.core.model.Term"}},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.isNone"}, "type": {"variable": "hydra.core.model.Term"}}},
                                                                                "argument": {"variable": "mt"}}}}}}},
                                                                    "argument": {"variable": "environment"}}}}}}}},
                                                      {
                                                        "name": "metadata",
                                                        "term": {
                                                          "typeApplication": {
                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                            "type": {"variable": "hydra.core.model.Term"}}}},
                                                      {"name": "primitives", "term": {"variable": "primitives"}},
                                                      {
                                                        "name": "schemaTypes",
                                                        "term": {
                                                          "typeApplication": {
                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                            "type": {"variable": "hydra.core.model.TypeScheme"}}}},
                                                      {
                                                        "name": "typeVariables",
                                                        "term": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}]}}}}}}}}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Build a Graph from element bindings, environment, and primitives"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.chooseUniqueName",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"set": {"variable": "hydra.core.model.Name"}}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.model.Name"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "reserved",
                "domain": {"set": {"variable": "hydra.core.model.Name"}},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "tryName",
                            "term": {
                              "lambda": {
                                "parameter": "index",
                                "domain": {"literal": {"integer": "int32"}},
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "candidate",
                                        "term": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": {"integer": "int32"}}}},
                                                            "argument": {"variable": "index"}}},
                                                        "argument": {"literal": {"integer": {"int32": 1}}}}}}},
                                                "argument": {"variable": "name"}}},
                                            "argument": {
                                              "wrap": {
                                                "typeName": "hydra.core.model.Name",
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                        "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "name"}}}}},
                                                    "argument": {"application": {"function": {"variable": "hydra.core.lib.literals.printInt32"}, "argument": {"variable": "index"}}}}}}}}},
                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.member"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "argument": {"variable": "candidate"}}},
                                                    "argument": {"variable": "reserved"}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {"variable": "tryName"},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.math.add"}, "type": {"literal": {"integer": "int32"}}}},
                                                        "argument": {"variable": "index"}}},
                                                    "argument": {"literal": {"integer": {"int32": 1}}}}}}}}},
                                        "argument": {"variable": "candidate"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {"function": {"domain": {"literal": {"integer": "int32"}}, "codomain": {"variable": "hydra.core.model.Name"}}},
                              "constraints": []}}],
                        "body": {"application": {"function": {"variable": "tryName"}, "argument": {"literal": {"integer": {"int32": 1}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Pick a name that does not collide with a reserved set, by appending a numeric suffix to the requested name when necessary"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.dereferenceSchemaType",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {
              "name": "arg1",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
              "isLazy": false}],
          "result": {"type": {"optional": {"variable": "hydra.core.model.TypeScheme"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "name",
                "domain": {"variable": "hydra.core.model.Name"},
                "body": {
                  "lambda": {
                    "parameter": "types",
                    "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "forType",
                            "term": {
                              "lambda": {
                                "parameter": "t",
                                "domain": {"variable": "hydra.core.model.Type"},
                                "body": {
                                  "application": {
                                    "function": {
                                      "cases": {
                                        "typeName": "hydra.core.model.Type",
                                        "default": {
                                          "optional": {
                                            "record": {
                                              "typeName": "hydra.core.model.TypeScheme",
                                              "fields": [
                                                {
                                                  "name": "variables",
                                                  "term": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Name"}}}},
                                                {"name": "body", "term": {"variable": "t"}},
                                                {
                                                  "name": "constraints",
                                                  "term": {
                                                    "typeApplication": {
                                                      "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                      "type": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}]}}},
                                        "cases": [
                                          {
                                            "name": "annotated",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "at",
                                                "domain": {"variable": "hydra.core.model.AnnotatedType"},
                                                "body": {
                                                  "application": {
                                                    "function": {"variable": "forType"},
                                                    "argument": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.model.AnnotatedType", "fieldName": "body"}},
                                                        "argument": {"variable": "at"}}}}}}}},
                                          {
                                            "name": "forall",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "ft",
                                                "domain": {"variable": "hydra.core.model.ForallType"},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                            "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                        "argument": {
                                                          "lambda": {
                                                            "parameter": "ts",
                                                            "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                            "body": {
                                                              "record": {
                                                                "typeName": "hydra.core.model.TypeScheme",
                                                                "fields": [
                                                                  {
                                                                    "name": "variables",
                                                                    "term": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.cons"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
                                                                                "argument": {"variable": "ft"}}}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
                                                                            "argument": {"variable": "ts"}}}}}},
                                                                  {
                                                                    "name": "body",
                                                                    "term": {
                                                                      "application": {
                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                                                        "argument": {"variable": "ts"}}}},
                                                                  {
                                                                    "name": "constraints",
                                                                    "term": {
                                                                      "application": {
                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "constraints"}},
                                                                        "argument": {"variable": "ts"}}}}]}}}}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {"variable": "forType"},
                                                        "argument": {
                                                          "application": {
                                                            "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "body"}},
                                                            "argument": {"variable": "ft"}}}}}}}}}},
                                          {
                                            "name": "variable",
                                            "handler": {
                                              "lambda": {
                                                "parameter": "v",
                                                "domain": {"variable": "hydra.core.model.Name"},
                                                "body": {
                                                  "application": {
                                                    "function": {"application": {"function": {"variable": "hydra.core.lexical.dereferenceSchemaType"}, "argument": {"variable": "v"}}},
                                                    "argument": {"variable": "types"}}}}}}]}},
                                    "argument": {"variable": "t"}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"optional": {"variable": "hydra.core.model.TypeScheme"}}}},
                              "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.bind"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                    "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                "argument": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                        "argument": {"variable": "name"}}},
                                    "argument": {"variable": "types"}}}}},
                            "argument": {
                              "lambda": {
                                "parameter": "ts",
                                "domain": {"variable": "hydra.core.model.TypeScheme"},
                                "body": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                            "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                        "argument": {
                                          "lambda": {
                                            "parameter": "ts2",
                                            "domain": {"variable": "hydra.core.model.TypeScheme"},
                                            "body": {
                                              "record": {
                                                "typeName": "hydra.core.model.TypeScheme",
                                                "fields": [
                                                  {
                                                    "name": "variables",
                                                    "term": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {
                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat2"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
                                                                "argument": {"variable": "ts"}}}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
                                                            "argument": {"variable": "ts2"}}}}}},
                                                  {
                                                    "name": "body",
                                                    "term": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                                        "argument": {"variable": "ts2"}}}},
                                                  {
                                                    "name": "constraints",
                                                    "term": {
                                                      "application": {
                                                        "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "constraints"}},
                                                        "argument": {"variable": "ts2"}}}}]}}}}}},
                                    "argument": {
                                      "application": {
                                        "function": {"variable": "forType"},
                                        "argument": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                            "argument": {"variable": "ts"}}}}}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Resolve a schema type through a chain of zero or more typedefs"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.dereferenceVariable",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {
            "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Binding"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                    "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Binding"}}}}},
                                "argument": {
                                  "application": {
                                    "function": {"application": {"function": {"variable": "hydra.core.lexical.lookupBinding"}, "argument": {"variable": "graph"}}},
                                    "argument": {"variable": "name"}}}}},
                            "argument": {
                              "typeApplication": {
                                "body": {
                                  "typeApplication": {
                                    "body": {
                                      "either": {
                                        "left": {
                                          "inject": {
                                            "typeName": "hydra.core.errors.Error",
                                            "field": {
                                              "name": "resolution",
                                              "term": {
                                                "inject": {
                                                  "typeName": "hydra.core.errors.ResolutionError",
                                                  "field": {
                                                    "name": "noSuchBinding",
                                                    "term": {
                                                      "record": {"typeName": "hydra.core.errors.NoSuchBindingError", "fields": [{"name": "name", "term": {"variable": "name"}}]}}}}}}}}}},
                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                "type": {"variable": "hydra.core.model.Binding"}}}}},
                        "argument": {
                          "lambda": {
                            "parameter": "right_",
                            "domain": {"variable": "hydra.core.model.Binding"},
                            "body": {
                              "typeApplication": {
                                "body": {
                                  "typeApplication": {"body": {"either": {"right": {"variable": "right_"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                "type": {"variable": "hydra.core.model.Binding"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Look up a binding by name in a graph, returning Either an error or the binding"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.elementsToGraph",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {
              "name": "arg1",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
              "isLazy": false},
            {"name": "arg2", "type": {"list": {"variable": "hydra.core.model.Binding"}}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.graph.Graph"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "parent",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "schemaTypes",
                    "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                    "body": {
                      "lambda": {
                        "parameter": "elements",
                        "domain": {"list": {"variable": "hydra.core.model.Binding"}},
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "prims",
                                "term": {
                                  "application": {
                                    "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "primitives"}},
                                    "argument": {"variable": "parent"}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.graph.Primitive"}}},
                                  "constraints": []}}],
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "g",
                                    "term": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {"application": {"function": {"variable": "hydra.core.lexical.buildGraph"}, "argument": {"variable": "elements"}}},
                                            "argument": {
                                              "typeApplication": {
                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                "type": {"optional": {"variable": "hydra.core.model.Term"}}}}}},
                                        "argument": {"variable": "prims"}}},
                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
                                "body": {
                                  "record": {
                                    "typeName": "hydra.core.graph.Graph",
                                    "fields": [
                                      {
                                        "name": "boundTerms",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTerms"}},
                                            "argument": {"variable": "g"}}}},
                                      {
                                        "name": "boundTypes",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
                                            "argument": {"variable": "g"}}}},
                                      {
                                        "name": "classConstraints",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "classConstraints"}},
                                            "argument": {"variable": "g"}}}},
                                      {
                                        "name": "lambdaVariables",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "lambdaVariables"}},
                                            "argument": {"variable": "g"}}}},
                                      {
                                        "name": "metadata",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "metadata"}},
                                            "argument": {"variable": "g"}}}},
                                      {
                                        "name": "primitives",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "primitives"}},
                                            "argument": {"variable": "g"}}}},
                                      {"name": "schemaTypes", "term": {"variable": "schemaTypes"}},
                                      {
                                        "name": "typeVariables",
                                        "term": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "typeVariables"}},
                                            "argument": {"variable": "g"}}}}]}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Create a graph from a parent graph, schema types, and list of element bindings"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.emptyGraph",
        "signature": {"typeParameters": [], "parameters": [], "result": {"type": {"variable": "hydra.core.graph.Graph"}}},
        "body": {
          "annotated": {
            "body": {
              "record": {
                "typeName": "hydra.core.graph.Graph",
                "fields": [
                  {
                    "name": "boundTerms",
                    "term": {
                      "typeApplication": {
                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                        "type": {"variable": "hydra.core.model.Term"}}}},
                  {
                    "name": "boundTypes",
                    "term": {
                      "typeApplication": {
                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                        "type": {"variable": "hydra.core.model.TypeScheme"}}}},
                  {
                    "name": "classConstraints",
                    "term": {
                      "typeApplication": {
                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                        "type": {"variable": "hydra.core.model.TypeVariableConstraints"}}}},
                  {
                    "name": "lambdaVariables",
                    "term": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}},
                  {
                    "name": "metadata",
                    "term": {
                      "typeApplication": {
                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                        "type": {"variable": "hydra.core.model.Term"}}}},
                  {
                    "name": "primitives",
                    "term": {
                      "typeApplication": {
                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                        "type": {"variable": "hydra.core.graph.Primitive"}}}},
                  {
                    "name": "schemaTypes",
                    "term": {
                      "typeApplication": {
                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                        "type": {"variable": "hydra.core.model.TypeScheme"}}}},
                  {
                    "name": "typeVariables",
                    "term": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.empty"}, "type": {"variable": "hydra.core.model.Name"}}}}]}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "An empty graph; no elements, no primitives, no schema."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.emptyInferenceContext",
        "signature": {"typeParameters": [], "parameters": [], "result": {"type": {"variable": "hydra.core.typing.InferenceContext"}}},
        "body": {
          "annotated": {
            "body": {
              "record": {
                "typeName": "hydra.core.typing.InferenceContext",
                "fields": [
                  {"name": "freshTypeVariableCount", "term": {"literal": {"integer": {"int32": 0}}}},
                  {
                    "name": "trace",
                    "term": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.paths.SubtermStep"}}}}]}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "An empty inference context; fresh-variable counter at zero and empty trace."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.fieldsOf",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"list": {"variable": "hydra.core.model.FieldType"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "t",
                "domain": {"variable": "hydra.core.model.Type"},
                "body": {
                  "let": {
                    "bindings": [
                      {
                        "name": "stripped",
                        "term": {"application": {"function": {"variable": "hydra.core.strip.deannotateType"}, "argument": {"variable": "t"}}},
                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                    "body": {
                      "application": {
                        "function": {
                          "cases": {
                            "typeName": "hydra.core.model.Type",
                            "default": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.FieldType"}}},
                            "cases": [
                              {
                                "name": "forall",
                                "handler": {
                                  "lambda": {
                                    "parameter": "forallType",
                                    "domain": {"variable": "hydra.core.model.ForallType"},
                                    "body": {
                                      "application": {
                                        "function": {"variable": "hydra.core.lexical.fieldsOf"},
                                        "argument": {
                                          "application": {
                                            "function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "body"}},
                                            "argument": {"variable": "forallType"}}}}}}}},
                              {
                                "name": "record",
                                "handler": {
                                  "lambda": {"parameter": "rt", "domain": {"list": {"variable": "hydra.core.model.FieldType"}}, "body": {"variable": "rt"}}}},
                              {
                                "name": "union",
                                "handler": {
                                  "lambda": {"parameter": "rt", "domain": {"list": {"variable": "hydra.core.model.FieldType"}}, "body": {"variable": "rt"}}}}]}},
                        "argument": {"variable": "stripped"}}}}}}},
            "annotation": {
              "map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Extract the fields of a record or union type"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.getField",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}, {"name": "t1", "constraints": []}],
          "parameters": [
            {
              "name": "arg0",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "t0"}}},
              "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {
              "name": "arg2",
              "type": {
                "function": {
                  "domain": {"variable": "t0"},
                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t1"}}}}},
              "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t1"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "typeLambda": {
                "parameter": "t1",
                "body": {
                  "annotated": {
                    "body": {
                      "lambda": {
                        "parameter": "m",
                        "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "t0"}}},
                        "body": {
                          "lambda": {
                            "parameter": "fname",
                            "domain": {"variable": "hydra.core.model.Name"},
                            "body": {
                              "lambda": {
                                "parameter": "decode",
                                "domain": {
                                  "function": {
                                    "domain": {"variable": "t0"},
                                    "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t1"}}}}},
                                "body": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "t0"}}},
                                                "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t1"}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "type": {"variable": "t0"}}},
                                                    "argument": {"variable": "fname"}}},
                                                "argument": {"variable": "m"}}}}},
                                        "argument": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {
                                                "body": {
                                                  "either": {
                                                    "left": {
                                                      "inject": {
                                                        "typeName": "hydra.core.errors.Error",
                                                        "field": {
                                                          "name": "resolution",
                                                          "term": {
                                                            "inject": {
                                                              "typeName": "hydra.core.errors.ResolutionError",
                                                              "field": {
                                                                "name": "noMatchingField",
                                                                "term": {
                                                                  "record": {"typeName": "hydra.core.errors.NoMatchingFieldError", "fields": [{"name": "fieldName", "term": {"variable": "fname"}}]}}}}}}}}}},
                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                            "type": {"variable": "t1"}}}}},
                                    "argument": {"variable": "decode"}}}}}}}}},
                    "annotation": {
                      "map": [
                        {
                          "key": {"variable": "description"},
                          "value": {
                            "literal": {"string": "Look up a field by name in a record's field map and decode its value, failing if the field is missing"}}}]}}}}}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.graphToBindings",
        "signature": {
          "typeParameters": [],
          "parameters": [{"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false}],
          "result": {"type": {"list": {"variable": "hydra.core.model.Binding"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "g",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "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.Binding"}}},
                        "argument": {
                          "lambda": {
                            "parameter": "p",
                            "domain": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "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": "hydra.core.model.Name"}}},
                                            "type": {"variable": "hydra.core.model.Term"}}},
                                        "argument": {"variable": "p"}}},
                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "term",
                                        "term": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                "type": {"variable": "hydra.core.model.Term"}}},
                                            "argument": {"variable": "p"}}},
                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                    "body": {
                                      "record": {
                                        "typeName": "hydra.core.model.Binding",
                                        "fields": [
                                          {"name": "name", "term": {"variable": "name"}},
                                          {"name": "term", "term": {"variable": "term"}},
                                          {
                                            "name": "typeScheme",
                                            "term": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                    "argument": {"variable": "name"}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
                                                    "argument": {"variable": "g"}}}}}}]}}}}}}}}}},
                    "argument": {
                      "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": {
                          "application": {
                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTerms"}},
                            "argument": {"variable": "g"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Reconstruct a list of Bindings from a Graph's boundTerms and boundTypes"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.graphWithPrimitives",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"list": {"variable": "hydra.core.graph.Primitive"}}, "isLazy": false},
            {"name": "arg1", "type": {"list": {"variable": "hydra.core.graph.Primitive"}}, "isLazy": false}],
          "result": {"type": {"variable": "hydra.core.graph.Graph"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "builtIn",
                "domain": {"list": {"variable": "hydra.core.graph.Primitive"}},
                "body": {
                  "lambda": {
                    "parameter": "userProvided",
                    "domain": {"list": {"variable": "hydra.core.graph.Primitive"}},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "toMap",
                            "term": {
                              "lambda": {
                                "parameter": "ps",
                                "domain": {"list": {"variable": "hydra.core.graph.Primitive"}},
                                "body": {
                                  "application": {
                                    "function": {
                                      "typeApplication": {
                                        "body": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                        "type": {"variable": "hydra.core.graph.Primitive"}}},
                                    "argument": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.graph.Primitive"}}},
                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.graph.Primitive"}}}}},
                                            "argument": {
                                              "lambda": {
                                                "parameter": "p",
                                                "domain": {"variable": "hydra.core.graph.Primitive"},
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "pair": {
                                                            "first": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.packaging.PrimitiveDefinition", "fieldName": "name"}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.graph.Primitive", "fieldName": "definition"}},
                                                                    "argument": {"variable": "p"}}}}},
                                                            "second": {"variable": "p"}}},
                                                        "type": {"variable": "hydra.core.model.Name"}}},
                                                    "type": {"variable": "hydra.core.graph.Primitive"}}}}}}},
                                        "argument": {"variable": "ps"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {
                                  "domain": {"list": {"variable": "hydra.core.graph.Primitive"}},
                                  "codomain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.graph.Primitive"}}}}},
                              "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "prims",
                                "term": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.union"}, "type": {"variable": "hydra.core.model.Name"}}},
                                            "type": {"variable": "hydra.core.graph.Primitive"}}},
                                        "argument": {"application": {"function": {"variable": "toMap"}, "argument": {"variable": "userProvided"}}}}},
                                    "argument": {"application": {"function": {"variable": "toMap"}, "argument": {"variable": "builtIn"}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.graph.Primitive"}}},
                                  "constraints": []}}],
                            "body": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {"variable": "hydra.core.lexical.buildGraph"},
                                        "argument": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.model.Binding"}}}}},
                                    "argument": {
                                      "typeApplication": {
                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
                                        "type": {"optional": {"variable": "hydra.core.model.Term"}}}}}},
                                "argument": {"variable": "prims"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Build a graph with primitives assembled from built-in and user-provided lists. User-provided primitives shadow built-in ones."}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.lookupBinding",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {"type": {"optional": {"variable": "hydra.core.model.Binding"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {
                              "typeApplication": {
                                "body": {
                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.Term"}}},
                                "type": {"variable": "hydra.core.model.Binding"}}},
                            "argument": {
                              "lambda": {
                                "parameter": "term",
                                "domain": {"variable": "hydra.core.model.Term"},
                                "body": {
                                  "record": {
                                    "typeName": "hydra.core.model.Binding",
                                    "fields": [
                                      {"name": "name", "term": {"variable": "name"}},
                                      {"name": "term", "term": {"variable": "term"}},
                                      {
                                        "name": "typeScheme",
                                        "term": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                    "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                "argument": {"variable": "name"}}},
                                            "argument": {
                                              "application": {
                                                "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
                                                "argument": {"variable": "graph"}}}}}}]}}}}}},
                        "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": {
                              "application": {
                                "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTerms"}},
                                "argument": {"variable": "graph"}}}}}}}}}}},
            "annotation": {
              "map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Look up a binding in a graph by name"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.lookupPrimitive",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {"type": {"optional": {"variable": "hydra.core.graph.Primitive"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "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.graph.Primitive"}}},
                            "argument": {"variable": "name"}}},
                        "argument": {
                          "application": {
                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "primitives"}},
                            "argument": {"variable": "graph"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Look up a primitive function in a graph by name"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.lookupTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {"type": {"optional": {"variable": "hydra.core.model.Term"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "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.model.Term"}}},
                            "argument": {"variable": "name"}}},
                        "argument": {
                          "application": {
                            "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTerms"}},
                            "argument": {"variable": "graph"}}}}}}}}},
            "annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Look up a term by name in a graph"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.matchEnum",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {
              "name": "arg2",
              "type": {"list": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "t0"}}}},
              "isLazy": false},
            {"name": "arg3", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "graph",
                    "domain": {"variable": "hydra.core.graph.Graph"},
                    "body": {
                      "lambda": {
                        "parameter": "tname",
                        "domain": {"variable": "hydra.core.model.Name"},
                        "body": {
                          "lambda": {
                            "parameter": "pairs",
                            "domain": {"list": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "t0"}}}},
                            "body": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lexical.matchUnion"}, "type": {"variable": "t0"}}},
                                        "argument": {"variable": "graph"}}},
                                    "argument": {"variable": "tname"}}},
                                "argument": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {
                                                "body": {"variable": "hydra.core.lib.lists.map"},
                                                "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "t0"}}}}},
                                            "type": {
                                              "pair": {
                                                "first": {"variable": "hydra.core.model.Name"},
                                                "second": {
                                                  "function": {
                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                    "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}}}}}},
                                        "argument": {
                                          "lambda": {
                                            "parameter": "pair",
                                            "domain": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "t0"}}},
                                            "body": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lexical.matchUnitField"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                "type": {"variable": "t0"}}},
                                                            "type": {"variable": "hydra.core.model.Term"}}},
                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                            "type": {"variable": "t0"}}},
                                                        "argument": {"variable": "pair"}}}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                        "type": {"variable": "t0"}}},
                                                    "argument": {"variable": "pair"}}}}}}}}},
                                    "argument": {"variable": "pairs"}}}}}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {
                        "literal": {"string": "Match a term against an enum type, dispatching on the variant name to a value from the supplied list"}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.matchRecord",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}, {"name": "t1", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "isLazy": false},
            {
              "name": "arg1",
              "type": {
                "function": {
                  "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
                  "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t1"}}}}},
              "isLazy": false},
            {"name": "arg2", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t1"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "typeLambda": {
                "parameter": "t1",
                "body": {
                  "annotated": {
                    "body": {
                      "lambda": {
                        "parameter": "graph",
                        "domain": {"variable": "t0"},
                        "body": {
                          "lambda": {
                            "parameter": "decode",
                            "domain": {
                              "function": {
                                "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
                                "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t1"}}}}},
                            "body": {
                              "lambda": {
                                "parameter": "term",
                                "domain": {"variable": "hydra.core.model.Term"},
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "stripped",
                                        "term": {
                                          "application": {"function": {"variable": "hydra.core.strip.deannotateAndDetypeTerm"}, "argument": {"variable": "term"}}},
                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                    "body": {
                                      "application": {
                                        "function": {
                                          "cases": {
                                            "typeName": "hydra.core.model.Term",
                                            "default": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "either": {
                                                        "left": {
                                                          "inject": {
                                                            "typeName": "hydra.core.errors.Error",
                                                            "field": {
                                                              "name": "resolution",
                                                              "term": {
                                                                "inject": {
                                                                  "typeName": "hydra.core.errors.ResolutionError",
                                                                  "field": {
                                                                    "name": "unexpectedShape",
                                                                    "term": {
                                                                      "record": {
                                                                        "typeName": "hydra.core.errors.UnexpectedShapeError",
                                                                        "fields": [
                                                                          {"name": "expected", "term": {"literal": {"string": "record"}}},
                                                                          {
                                                                            "name": "actual",
                                                                            "term": {"application": {"function": {"variable": "hydra.core.print.model.term"}, "argument": {"variable": "term"}}}}]}}}}}}}}}},
                                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                                "type": {"variable": "t1"}}},
                                            "cases": [
                                              {
                                                "name": "record",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "record",
                                                    "domain": {"variable": "hydra.core.model.Record"},
                                                    "body": {
                                                      "application": {
                                                        "function": {"variable": "decode"},
                                                        "argument": {
                                                          "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.Field"}}},
                                                                        "type": {"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.Term"}}}}},
                                                                    "argument": {
                                                                      "lambda": {
                                                                        "parameter": "field",
                                                                        "domain": {"variable": "hydra.core.model.Field"},
                                                                        "body": {
                                                                          "typeApplication": {
                                                                            "body": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "pair": {
                                                                                    "first": {
                                                                                      "application": {
                                                                                        "function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "name"}},
                                                                                        "argument": {"variable": "field"}}},
                                                                                    "second": {
                                                                                      "application": {
                                                                                        "function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "term"}},
                                                                                        "argument": {"variable": "field"}}}}},
                                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                                            "type": {"variable": "hydra.core.model.Term"}}}}}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.model.Record", "fieldName": "fields"}},
                                                                    "argument": {"variable": "record"}}}}}}}}}}}}]}},
                                        "argument": {"variable": "stripped"}}}}}}}}}}},
                    "annotation": {
                      "map": [
                        {
                          "key": {"variable": "description"},
                          "value": {"literal": {"string": "Match a term against a record type and decode its fields, failing if the term is not a record"}}}]}}}}}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.matchUnion",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {
              "name": "arg2",
              "type": {
                "list": {
                  "pair": {
                    "first": {"variable": "hydra.core.model.Name"},
                    "second": {
                      "function": {
                        "domain": {"variable": "hydra.core.model.Term"},
                        "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}}}}},
              "isLazy": false},
            {"name": "arg3", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "graph",
                    "domain": {"variable": "hydra.core.graph.Graph"},
                    "body": {
                      "lambda": {
                        "parameter": "tname",
                        "domain": {"variable": "hydra.core.model.Name"},
                        "body": {
                          "lambda": {
                            "parameter": "pairs",
                            "domain": {
                              "list": {
                                "pair": {
                                  "first": {"variable": "hydra.core.model.Name"},
                                  "second": {
                                    "function": {
                                      "domain": {"variable": "hydra.core.model.Term"},
                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}}}}},
                            "body": {
                              "lambda": {
                                "parameter": "term",
                                "domain": {"variable": "hydra.core.model.Term"},
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "stripped",
                                        "term": {
                                          "application": {"function": {"variable": "hydra.core.strip.deannotateAndDetypeTerm"}, "argument": {"variable": "term"}}},
                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "mapping",
                                            "term": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.maps.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                    "type": {
                                                      "function": {
                                                        "domain": {"variable": "hydra.core.model.Term"},
                                                        "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}}}},
                                                "argument": {"variable": "pairs"}}},
                                            "typeScheme": {
                                              "variables": [],
                                              "body": {
                                                "map": {
                                                  "keys": {"variable": "hydra.core.model.Name"},
                                                  "values": {
                                                    "function": {
                                                      "domain": {"variable": "hydra.core.model.Term"},
                                                      "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}}}},
                                              "constraints": []}}],
                                        "body": {
                                          "application": {
                                            "function": {
                                              "cases": {
                                                "typeName": "hydra.core.model.Term",
                                                "default": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "either": {
                                                            "left": {
                                                              "inject": {
                                                                "typeName": "hydra.core.errors.Error",
                                                                "field": {
                                                                  "name": "resolution",
                                                                  "term": {
                                                                    "inject": {
                                                                      "typeName": "hydra.core.errors.ResolutionError",
                                                                      "field": {
                                                                        "name": "unexpectedShape",
                                                                        "term": {
                                                                          "record": {
                                                                            "typeName": "hydra.core.errors.UnexpectedShapeError",
                                                                            "fields": [
                                                                              {
                                                                                "name": "expected",
                                                                                "term": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "injection for type "}}}},
                                                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "tname"}}}}}},
                                                                              {
                                                                                "name": "actual",
                                                                                "term": {"application": {"function": {"variable": "hydra.core.print.model.term"}, "argument": {"variable": "stripped"}}}}]}}}}}}}}}},
                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                    "type": {"variable": "t0"}}},
                                                "cases": [
                                                  {
                                                    "name": "variable",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "name",
                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                        "body": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {
                                                                        "body": {
                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                                        "type": {"variable": "hydra.core.model.Binding"}}},
                                                                    "type": {"variable": "t0"}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"application": {"function": {"variable": "hydra.core.lexical.requireBinding"}, "argument": {"variable": "graph"}}},
                                                                    "argument": {"variable": "name"}}}}},
                                                            "argument": {
                                                              "lambda": {
                                                                "parameter": "el",
                                                                "domain": {"variable": "hydra.core.model.Binding"},
                                                                "body": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lexical.matchUnion"}, "type": {"variable": "t0"}}},
                                                                                "argument": {"variable": "graph"}}},
                                                                            "argument": {"variable": "tname"}}},
                                                                        "argument": {"variable": "pairs"}}},
                                                                    "argument": {
                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "el"}}}}}}}}}}}},
                                                  {
                                                    "name": "inject",
                                                    "handler": {
                                                      "lambda": {
                                                        "parameter": "injection",
                                                        "domain": {"variable": "hydra.core.model.Injection"},
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "exp",
                                                                "term": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "fname",
                                                                        "term": {
                                                                          "application": {
                                                                            "function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "name"}},
                                                                            "argument": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.Injection", "fieldName": "field"}},
                                                                                "argument": {"variable": "injection"}}}}},
                                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "val",
                                                                            "term": {
                                                                              "application": {
                                                                                "function": {"project": {"typeName": "hydra.core.model.Field", "fieldName": "term"}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {"project": {"typeName": "hydra.core.model.Injection", "fieldName": "field"}},
                                                                                    "argument": {"variable": "injection"}}}}},
                                                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "typeApplication": {
                                                                                            "body": {"variable": "hydra.core.lib.optionals.match"},
                                                                                            "type": {
                                                                                              "function": {
                                                                                                "domain": {"variable": "hydra.core.model.Term"},
                                                                                                "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}}}},
                                                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                "type": {
                                                                                                  "function": {
                                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                                    "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}}}},
                                                                                            "argument": {"variable": "fname"}}},
                                                                                        "argument": {"variable": "mapping"}}}}},
                                                                                "argument": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "either": {
                                                                                            "left": {
                                                                                              "inject": {
                                                                                                "typeName": "hydra.core.errors.Error",
                                                                                                "field": {
                                                                                                  "name": "resolution",
                                                                                                  "term": {
                                                                                                    "inject": {
                                                                                                      "typeName": "hydra.core.errors.ResolutionError",
                                                                                                      "field": {
                                                                                                        "name": "noMatchingField",
                                                                                                        "term": {
                                                                                                          "record": {"typeName": "hydra.core.errors.NoMatchingFieldError", "fields": [{"name": "fieldName", "term": {"variable": "fname"}}]}}}}}}}}}},
                                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                                    "type": {"variable": "t0"}}}}},
                                                                            "argument": {
                                                                              "lambda": {
                                                                                "parameter": "f",
                                                                                "domain": {
                                                                                  "function": {
                                                                                    "domain": {"variable": "hydra.core.model.Term"},
                                                                                    "codomain": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}},
                                                                                "body": {"application": {"function": {"variable": "f"}, "argument": {"variable": "val"}}}}}}}}}}},
                                                                "typeScheme": {
                                                                  "variables": [],
                                                                  "body": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}},
                                                                  "constraints": []}}],
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                            "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "t0"}}}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": "string"}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {"unwrap": "hydra.core.model.Name"},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {"project": {"typeName": "hydra.core.model.Injection", "fieldName": "typeName"}},
                                                                                        "argument": {"variable": "injection"}}}}}}},
                                                                            "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "tname"}}}}}}},
                                                                    "argument": {"variable": "exp"}}},
                                                                "argument": {
                                                                  "typeApplication": {
                                                                    "body": {
                                                                      "typeApplication": {
                                                                        "body": {
                                                                          "either": {
                                                                            "left": {
                                                                              "inject": {
                                                                                "typeName": "hydra.core.errors.Error",
                                                                                "field": {
                                                                                  "name": "resolution",
                                                                                  "term": {
                                                                                    "inject": {
                                                                                      "typeName": "hydra.core.errors.ResolutionError",
                                                                                      "field": {
                                                                                        "name": "unexpectedShape",
                                                                                        "term": {
                                                                                          "record": {
                                                                                            "typeName": "hydra.core.errors.UnexpectedShapeError",
                                                                                            "fields": [
                                                                                              {
                                                                                                "name": "expected",
                                                                                                "term": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "injection for type "}}}},
                                                                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "tname"}}}}}},
                                                                                              {
                                                                                                "name": "actual",
                                                                                                "term": {"application": {"function": {"variable": "hydra.core.print.model.term"}, "argument": {"variable": "term"}}}}]}}}}}}}}}},
                                                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                                                    "type": {"variable": "t0"}}}}}}}}}}]}},
                                            "argument": {"variable": "stripped"}}}}}}}}}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {
                        "literal": {
                          "string": "Match a term against a union type, dispatching on the injected variant to the appropriate decoder. Variable terms are dereferenced through the graph before matching."}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.matchUnitField",
        "signature": {
          "typeParameters": [
            {"name": "t0", "constraints": []},
            {"name": "t1", "constraints": []},
            {"name": "t2", "constraints": []},
            {"name": "t3", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "t1"}, "isLazy": false}],
          "result": {
            "type": {
              "pair": {
                "first": {"variable": "t0"},
                "second": {
                  "function": {"domain": {"variable": "t2"}, "codomain": {"either": {"left": {"variable": "t3"}, "right": {"variable": "t1"}}}}}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "typeLambda": {
                "parameter": "t1",
                "body": {
                  "typeLambda": {
                    "parameter": "t2",
                    "body": {
                      "typeLambda": {
                        "parameter": "t3",
                        "body": {
                          "annotated": {
                            "body": {
                              "lambda": {
                                "parameter": "fname",
                                "domain": {"variable": "t0"},
                                "body": {
                                  "lambda": {
                                    "parameter": "x",
                                    "domain": {"variable": "t1"},
                                    "body": {
                                      "typeApplication": {
                                        "body": {
                                          "typeApplication": {
                                            "body": {
                                              "pair": {
                                                "first": {"variable": "fname"},
                                                "second": {
                                                  "lambda": {
                                                    "parameter": "ignored",
                                                    "domain": {"variable": "t2"},
                                                    "body": {
                                                      "typeApplication": {
                                                        "body": {"typeApplication": {"body": {"either": {"right": {"variable": "x"}}}, "type": {"variable": "t3"}}},
                                                        "type": {"variable": "t1"}}}}}}},
                                            "type": {"variable": "t0"}}},
                                        "type": {
                                          "function": {"domain": {"variable": "t2"}, "codomain": {"either": {"left": {"variable": "t3"}, "right": {"variable": "t1"}}}}}}}}}}},
                            "annotation": {
                              "map": [
                                {
                                  "key": {"variable": "description"},
                                  "value": {
                                    "literal": {
                                      "string": "Build a (fieldName, decoder) pair for a unit-valued union variant: the decoder ignores its argument and returns a fixed value"}}}]}}}}}}}}}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.requireBinding",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {
            "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Binding"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "showAll",
                            "term": {"literal": {"boolean": false}},
                            "typeScheme": {"variables": [], "body": {"literal": "boolean"}, "constraints": []}}],
                        "body": {
                          "let": {
                            "bindings": [
                              {
                                "name": "ellipsis",
                                "term": {
                                  "lambda": {
                                    "parameter": "strings",
                                    "domain": {"list": {"literal": "string"}},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"list": {"literal": "string"}}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {"variable": "hydra.core.lib.logic.and"},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.gt"}, "type": {"literal": {"integer": "int32"}}}},
                                                                "argument": {
                                                                  "application": {
                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"literal": "string"}}},
                                                                    "argument": {"variable": "strings"}}}}},
                                                            "argument": {"literal": {"integer": {"int32": 3}}}}}}},
                                                    "argument": {"application": {"function": {"variable": "hydra.core.lib.logic.not"}, "argument": {"variable": "showAll"}}}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat2"}, "type": {"literal": "string"}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.take"}, "type": {"literal": "string"}}},
                                                            "argument": {"literal": {"integer": {"int32": 3}}}}},
                                                        "argument": {"variable": "strings"}}}}},
                                                "argument": {"list": [{"literal": {"string": "..."}}]}}}}},
                                        "argument": {"variable": "strings"}}}}},
                                "typeScheme": {
                                  "variables": [],
                                  "body": {"function": {"domain": {"list": {"literal": "string"}}, "codomain": {"list": {"literal": "string"}}}},
                                  "constraints": []}}],
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "errMsg",
                                    "term": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {"variable": "hydra.core.lib.strings.concat2"},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                    "argument": {
                                                      "application": {
                                                        "function": {
                                                          "application": {
                                                            "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                            "argument": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "no such element: "}}}},
                                                                "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "name"}}}}}}},
                                                        "argument": {"literal": {"string": ". Available elements: {"}}}}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {"application": {"function": {"variable": "hydra.core.lib.strings.join"}, "argument": {"literal": {"string": ", "}}}},
                                                    "argument": {
                                                      "application": {
                                                        "function": {"variable": "ellipsis"},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {
                                                                  "typeApplication": {
                                                                    "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                    "type": {"literal": "string"}}},
                                                                "argument": {"unwrap": "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": {
                                                                  "application": {
                                                                    "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTerms"}},
                                                                    "argument": {"variable": "graph"}}}}}}}}}}}}}}},
                                        "argument": {"literal": {"string": "}"}}}},
                                    "typeScheme": {"variables": [], "body": {"literal": "string"}, "constraints": []}}],
                                "body": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Binding"}}},
                                                "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Binding"}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {"application": {"function": {"variable": "hydra.core.lexical.lookupBinding"}, "argument": {"variable": "graph"}}},
                                                "argument": {"variable": "name"}}}}},
                                        "argument": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {
                                                "body": {
                                                  "either": {
                                                    "left": {
                                                      "inject": {
                                                        "typeName": "hydra.core.errors.Error",
                                                        "field": {
                                                          "name": "resolution",
                                                          "term": {
                                                            "inject": {
                                                              "typeName": "hydra.core.errors.ResolutionError",
                                                              "field": {
                                                                "name": "other",
                                                                "term": {"wrap": {"typeName": "hydra.core.errors.OtherResolutionError", "body": {"variable": "errMsg"}}}}}}}}}}},
                                                "type": {"variable": "hydra.core.errors.Error"}}},
                                            "type": {"variable": "hydra.core.model.Binding"}}}}},
                                    "argument": {
                                      "lambda": {
                                        "parameter": "x",
                                        "domain": {"variable": "hydra.core.model.Binding"},
                                        "body": {
                                          "typeApplication": {
                                            "body": {"typeApplication": {"body": {"either": {"right": {"variable": "x"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                            "type": {"variable": "hydra.core.model.Binding"}}}}}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {"string": "Look up a binding in a graph by name, failing with a list of available names if it is not found"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.requirePrimitive",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {
            "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.graph.Primitive"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.graph.Primitive"}}},
                                    "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.graph.Primitive"}}}}},
                                "argument": {
                                  "application": {
                                    "function": {"application": {"function": {"variable": "hydra.core.lexical.lookupPrimitive"}, "argument": {"variable": "graph"}}},
                                    "argument": {"variable": "name"}}}}},
                            "argument": {
                              "typeApplication": {
                                "body": {
                                  "typeApplication": {
                                    "body": {
                                      "either": {
                                        "left": {
                                          "inject": {
                                            "typeName": "hydra.core.errors.Error",
                                            "field": {
                                              "name": "resolution",
                                              "term": {
                                                "inject": {
                                                  "typeName": "hydra.core.errors.ResolutionError",
                                                  "field": {
                                                    "name": "noSuchPrimitive",
                                                    "term": {
                                                      "record": {"typeName": "hydra.core.errors.NoSuchPrimitiveError", "fields": [{"name": "name", "term": {"variable": "name"}}]}}}}}}}}}},
                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                "type": {"variable": "hydra.core.graph.Primitive"}}}}},
                        "argument": {
                          "lambda": {
                            "parameter": "x",
                            "domain": {"variable": "hydra.core.graph.Primitive"},
                            "body": {
                              "typeApplication": {
                                "body": {"typeApplication": {"body": {"either": {"right": {"variable": "x"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                "type": {"variable": "hydra.core.graph.Primitive"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Look up a primitive in a graph by name, failing if it is not registered"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.requirePrimitiveType",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {
            "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.TypeScheme"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "tx",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "mts",
                            "term": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "typeApplication": {
                                        "body": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.graph.Primitive"}}},
                                        "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                    "argument": {
                                      "lambda": {
                                        "parameter": "_p",
                                        "domain": {"variable": "hydra.core.graph.Primitive"},
                                        "body": {
                                          "application": {
                                            "function": {"variable": "hydra.core.scoping.termSignatureToTypeScheme"},
                                            "argument": {
                                              "application": {
                                                "function": {"project": {"typeName": "hydra.core.packaging.PrimitiveDefinition", "fieldName": "signature"}},
                                                "argument": {
                                                  "application": {
                                                    "function": {"project": {"typeName": "hydra.core.graph.Primitive", "fieldName": "definition"}},
                                                    "argument": {"variable": "_p"}}}}}}}}}}},
                                "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.graph.Primitive"}}},
                                        "argument": {"variable": "name"}}},
                                    "argument": {
                                      "application": {
                                        "function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "primitives"}},
                                        "argument": {"variable": "tx"}}}}}}},
                            "typeScheme": {"variables": [], "body": {"optional": {"variable": "hydra.core.model.TypeScheme"}}, "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": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.TypeScheme"}}}}},
                                    "argument": {"variable": "mts"}}},
                                "argument": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {
                                        "body": {
                                          "either": {
                                            "left": {
                                              "inject": {
                                                "typeName": "hydra.core.errors.Error",
                                                "field": {
                                                  "name": "resolution",
                                                  "term": {
                                                    "inject": {
                                                      "typeName": "hydra.core.errors.ResolutionError",
                                                      "field": {
                                                        "name": "noSuchPrimitive",
                                                        "term": {
                                                          "record": {"typeName": "hydra.core.errors.NoSuchPrimitiveError", "fields": [{"name": "name", "term": {"variable": "name"}}]}}}}}}}}}},
                                        "type": {"variable": "hydra.core.errors.Error"}}},
                                    "type": {"variable": "hydra.core.model.TypeScheme"}}}}},
                            "argument": {
                              "lambda": {
                                "parameter": "ts",
                                "domain": {"variable": "hydra.core.model.TypeScheme"},
                                "body": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"either": {"right": {"variable": "ts"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                    "type": {"variable": "hydra.core.model.TypeScheme"}}}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {"string": "Look up a primitive's type scheme in a graph by name, failing if the primitive is not registered"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.requireTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "application": {
                        "function": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Term"}}},
                                    "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                "argument": {
                                  "application": {
                                    "function": {"application": {"function": {"variable": "hydra.core.lexical.resolveTerm"}, "argument": {"variable": "graph"}}},
                                    "argument": {"variable": "name"}}}}},
                            "argument": {
                              "typeApplication": {
                                "body": {
                                  "typeApplication": {
                                    "body": {
                                      "either": {
                                        "left": {
                                          "inject": {
                                            "typeName": "hydra.core.errors.Error",
                                            "field": {
                                              "name": "resolution",
                                              "term": {
                                                "inject": {
                                                  "typeName": "hydra.core.errors.ResolutionError",
                                                  "field": {
                                                    "name": "noSuchBinding",
                                                    "term": {
                                                      "record": {"typeName": "hydra.core.errors.NoSuchBindingError", "fields": [{"name": "name", "term": {"variable": "name"}}]}}}}}}}}}},
                                    "type": {"variable": "hydra.core.errors.Error"}}},
                                "type": {"variable": "hydra.core.model.Term"}}}}},
                        "argument": {
                          "lambda": {
                            "parameter": "x",
                            "domain": {"variable": "hydra.core.model.Term"},
                            "body": {
                              "typeApplication": {
                                "body": {"typeApplication": {"body": {"either": {"right": {"variable": "x"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                "type": {"variable": "hydra.core.model.Term"}}}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {"string": "Resolve a name to a term in the graph, following variable references, and fail if the name is not bound"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.resolveTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false}],
          "result": {"type": {"optional": {"variable": "hydra.core.model.Term"}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "name",
                    "domain": {"variable": "hydra.core.model.Name"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "recurse",
                            "term": {
                              "lambda": {
                                "parameter": "term",
                                "domain": {"variable": "hydra.core.model.Term"},
                                "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": {
                                          "cases": {
                                            "typeName": "hydra.core.model.Term",
                                            "default": {"optional": {"variable": "term"}},
                                            "cases": [
                                              {
                                                "name": "variable",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "name'",
                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                    "body": {
                                                      "application": {
                                                        "function": {"application": {"function": {"variable": "hydra.core.lexical.resolveTerm"}, "argument": {"variable": "graph"}}},
                                                        "argument": {"variable": "name'"}}}}}}]}},
                                        "argument": {"variable": "stripped"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"optional": {"variable": "hydra.core.model.Term"}}}},
                              "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "typeApplication": {
                                        "body": {
                                          "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Term"}}},
                                        "type": {"optional": {"variable": "hydra.core.model.Term"}}}},
                                    "argument": {
                                      "application": {
                                        "function": {"application": {"function": {"variable": "hydra.core.lexical.lookupTerm"}, "argument": {"variable": "graph"}}},
                                        "argument": {"variable": "name"}}}}},
                                "argument": {"typeApplication": {"body": {"optional": null}, "type": {"variable": "hydra.core.model.Term"}}}}},
                            "argument": {"variable": "recurse"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "TODO: distinguish between lambda-bound and let-bound variables"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.stripAndDereferenceTerm",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "term",
                    "domain": {"variable": "hydra.core.model.Term"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "stripped",
                            "term": {
                              "application": {"function": {"variable": "hydra.core.strip.deannotateAndDetypeTerm"}, "argument": {"variable": "term"}}},
                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "cases": {
                                "typeName": "hydra.core.model.Term",
                                "default": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"either": {"right": {"variable": "stripped"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                    "type": {"variable": "hydra.core.model.Term"}}},
                                "cases": [
                                  {
                                    "name": "variable",
                                    "handler": {
                                      "lambda": {
                                        "parameter": "v",
                                        "domain": {"variable": "hydra.core.model.Name"},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                        "type": {"variable": "hydra.core.model.Term"}}},
                                                    "type": {"variable": "hydra.core.model.Term"}}},
                                                "argument": {
                                                  "application": {
                                                    "function": {"application": {"function": {"variable": "hydra.core.lexical.requireTerm"}, "argument": {"variable": "graph"}}},
                                                    "argument": {"variable": "v"}}}}},
                                            "argument": {
                                              "lambda": {
                                                "parameter": "t",
                                                "domain": {"variable": "hydra.core.model.Term"},
                                                "body": {
                                                  "application": {
                                                    "function": {
                                                      "application": {"function": {"variable": "hydra.core.lexical.stripAndDereferenceTerm"}, "argument": {"variable": "graph"}}},
                                                    "argument": {"variable": "t"}}}}}}}}}}]}},
                            "argument": {"variable": "stripped"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Strip annotations and type lambdas/applications from a term, then follow variable references through the graph until a non-variable term is reached"}}}]}}}}},
    {
      "term": {
        "name": "hydra.core.lexical.stripAndDereferenceTermEither",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
          "result": {"type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "graph",
                "domain": {"variable": "hydra.core.graph.Graph"},
                "body": {
                  "lambda": {
                    "parameter": "term",
                    "domain": {"variable": "hydra.core.model.Term"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "stripped",
                            "term": {
                              "application": {"function": {"variable": "hydra.core.strip.deannotateAndDetypeTerm"}, "argument": {"variable": "term"}}},
                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "cases": {
                                "typeName": "hydra.core.model.Term",
                                "default": {
                                  "typeApplication": {
                                    "body": {
                                      "typeApplication": {"body": {"either": {"right": {"variable": "stripped"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                    "type": {"variable": "hydra.core.model.Term"}}},
                                "cases": [
                                  {
                                    "name": "variable",
                                    "handler": {
                                      "lambda": {
                                        "parameter": "v",
                                        "domain": {"variable": "hydra.core.model.Name"},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.either"}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                            "type": {"variable": "hydra.core.model.Binding"}}},
                                                        "type": {"either": {"left": {"variable": "hydra.core.errors.Error"}, "right": {"variable": "hydra.core.model.Term"}}}}},
                                                    "argument": {
                                                      "lambda": {
                                                        "parameter": "left_",
                                                        "domain": {"variable": "hydra.core.errors.Error"},
                                                        "body": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {"body": {"either": {"left": {"variable": "left_"}}}, "type": {"variable": "hydra.core.errors.Error"}}},
                                                            "type": {"variable": "hydra.core.model.Term"}}}}}}},
                                                "argument": {
                                                  "lambda": {
                                                    "parameter": "binding",
                                                    "domain": {"variable": "hydra.core.model.Binding"},
                                                    "body": {
                                                      "application": {
                                                        "function": {
                                                          "application": {"function": {"variable": "hydra.core.lexical.stripAndDereferenceTermEither"}, "argument": {"variable": "graph"}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}},
                                                            "argument": {"variable": "binding"}}}}}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {"application": {"function": {"variable": "hydra.core.lexical.dereferenceVariable"}, "argument": {"variable": "graph"}}},
                                                "argument": {"variable": "v"}}}}}}}}]}},
                            "argument": {"variable": "stripped"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {"literal": {"string": "Strip annotations and dereference variables, returning Either an error or the resolved term"}}}]}}}}}]}