packages feed

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

{
  "name": "hydra.core.unification",
  "metadata": {"description": "Utilities for type unification.", "comments": [], "seeAlso": [], "provisions": []},
  "dependencies": [
    {"module": "hydra.core.coders"},
    {"module": "hydra.core.errors"},
    {"module": "hydra.core.lib.eithers"},
    {"module": "hydra.core.lib.equality"},
    {"module": "hydra.core.lib.lists"},
    {"module": "hydra.core.lib.logic"},
    {"module": "hydra.core.lib.maps"},
    {"module": "hydra.core.lib.optionals"},
    {"module": "hydra.core.lib.pairs"},
    {"module": "hydra.core.lib.strings"},
    {"module": "hydra.core.model"},
    {"module": "hydra.core.print.model"},
    {"module": "hydra.core.rewriting"},
    {"module": "hydra.core.strip"},
    {"module": "hydra.core.substitution"},
    {"module": "hydra.core.typing"}],
  "definitions": [
    {
      "term": {
        "name": "hydra.core.unification.joinTypes",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false},
            {"name": "arg2", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false},
            {"name": "arg3", "type": {"literal": "string"}, "isLazy": false}],
          "result": {
            "type": {
              "either": {
                "left": {"variable": "hydra.core.errors.UnificationError"},
                "right": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "cx",
                    "domain": {"variable": "t0"},
                    "body": {
                      "lambda": {
                        "parameter": "left",
                        "domain": {"variable": "hydra.core.model.Type"},
                        "body": {
                          "lambda": {
                            "parameter": "right",
                            "domain": {"variable": "hydra.core.model.Type"},
                            "body": {
                              "lambda": {
                                "parameter": "comment",
                                "domain": {"literal": "string"},
                                "body": {
                                  "let": {
                                    "bindings": [
                                      {
                                        "name": "sleft",
                                        "term": {"application": {"function": {"variable": "hydra.core.strip.deannotateType"}, "argument": {"variable": "left"}}},
                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "sright",
                                            "term": {"application": {"function": {"variable": "hydra.core.strip.deannotateType"}, "argument": {"variable": "right"}}},
                                            "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                                        "body": {
                                          "let": {
                                            "bindings": [
                                              {
                                                "name": "joinOne",
                                                "term": {
                                                  "lambda": {
                                                    "parameter": "l",
                                                    "domain": {"variable": "hydra.core.model.Type"},
                                                    "body": {
                                                      "lambda": {
                                                        "parameter": "r",
                                                        "domain": {"variable": "hydra.core.model.Type"},
                                                        "body": {
                                                          "record": {
                                                            "typeName": "hydra.core.typing.TypeConstraint",
                                                            "fields": [
                                                              {"name": "left", "term": {"variable": "l"}},
                                                              {"name": "right", "term": {"variable": "r"}},
                                                              {
                                                                "name": "comment",
                                                                "term": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "join types; "}}}},
                                                                    "argument": {"variable": "comment"}}}}]}}}}}},
                                                "typeScheme": {
                                                  "variables": [],
                                                  "body": {
                                                    "function": {
                                                      "domain": {"variable": "hydra.core.model.Type"},
                                                      "codomain": {
                                                        "function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.typing.TypeConstraint"}}}}},
                                                  "constraints": []}}],
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "cannotUnify",
                                                    "term": {
                                                      "typeLambda": {
                                                        "parameter": "t1",
                                                        "body": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "either": {
                                                                    "left": {
                                                                      "record": {
                                                                        "typeName": "hydra.core.errors.UnificationError",
                                                                        "fields": [
                                                                          {"name": "leftType", "term": {"variable": "sleft"}},
                                                                          {"name": "rightType", "term": {"variable": "sright"}},
                                                                          {
                                                                            "name": "message",
                                                                            "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": {"literal": {"string": "cannot unify "}}}},
                                                                                                "argument": {"application": {"function": {"variable": "hydra.core.print.model.type"}, "argument": {"variable": "sleft"}}}}}}},
                                                                                        "argument": {"literal": {"string": " with "}}}}}},
                                                                                "argument": {"application": {"function": {"variable": "hydra.core.print.model.type"}, "argument": {"variable": "sright"}}}}}}]}}}},
                                                                "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                            "type": {"variable": "t1"}}}}},
                                                    "typeScheme": {
                                                      "variables": ["t1"],
                                                      "body": {"either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "t1"}}},
                                                      "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "assertEqual",
                                                        "term": {
                                                          "typeLambda": {
                                                            "parameter": "t1",
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "application": {
                                                                    "function": {
                                                                      "application": {
                                                                        "function": {
                                                                          "typeApplication": {
                                                                            "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                            "type": {"either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"list": {"variable": "t1"}}}}}},
                                                                        "argument": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                "argument": {"variable": "sleft"}}},
                                                                            "argument": {"variable": "sright"}}}}},
                                                                    "argument": {
                                                                      "typeApplication": {
                                                                        "body": {
                                                                          "typeApplication": {
                                                                            "body": {"either": {"right": {"typeApplication": {"body": {"list": []}, "type": {"variable": "t1"}}}}},
                                                                            "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                        "type": {"list": {"variable": "t1"}}}}}},
                                                                "argument": {"typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "t1"}}}}}}}},
                                                        "typeScheme": {
                                                          "variables": ["t1"],
                                                          "body": {"either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"list": {"variable": "t1"}}}},
                                                          "constraints": [{"key": "t1", "value": {"classes": []}}]}}],
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "joinList",
                                                            "term": {
                                                              "lambda": {
                                                                "parameter": "lefts",
                                                                "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                                                "body": {
                                                                  "lambda": {
                                                                    "parameter": "rights",
                                                                    "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                                                    "body": {
                                                                      "application": {
                                                                        "function": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "typeApplication": {
                                                                                    "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                    "type": {
                                                                                      "either": {
                                                                                        "left": {"variable": "hydra.core.errors.UnificationError"},
                                                                                        "right": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                            "argument": {"variable": "lefts"}}}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                        "argument": {"variable": "rights"}}}}}}},
                                                                            "argument": {
                                                                              "typeApplication": {
                                                                                "body": {
                                                                                  "typeApplication": {
                                                                                    "body": {
                                                                                      "either": {
                                                                                        "right": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.zipWith"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                        "type": {"variable": "hydra.core.typing.TypeConstraint"}}},
                                                                                                    "argument": {"variable": "joinOne"}}},
                                                                                                "argument": {"variable": "lefts"}}},
                                                                                            "argument": {"variable": "rights"}}}}},
                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}},
                                                                        "argument": {
                                                                          "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}}}},
                                                            "typeScheme": {
                                                              "variables": [],
                                                              "body": {
                                                                "function": {
                                                                  "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                                                  "codomain": {
                                                                    "function": {
                                                                      "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                                                      "codomain": {
                                                                        "either": {
                                                                          "left": {"variable": "hydra.core.errors.UnificationError"},
                                                                          "right": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}},
                                                              "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "joinRowTypes",
                                                                "term": {
                                                                  "lambda": {
                                                                    "parameter": "left",
                                                                    "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                    "body": {
                                                                      "lambda": {
                                                                        "parameter": "right",
                                                                        "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                        "body": {
                                                                          "application": {
                                                                            "function": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "typeApplication": {
                                                                                        "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                        "type": {
                                                                                          "either": {
                                                                                            "left": {"variable": "hydra.core.errors.UnificationError"},
                                                                                            "right": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {"variable": "hydra.core.lib.logic.and"},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": {"integer": "int32"}}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                        "argument": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "typeApplication": {
                                                                                                                    "body": {
                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.FieldType"}}},
                                                                                                                    "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                "argument": {"project": {"typeName": "hydra.core.model.FieldType", "fieldName": "name"}}}},
                                                                                                            "argument": {"variable": "left"}}}}}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.FieldType"}}},
                                                                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "argument": {"project": {"typeName": "hydra.core.model.FieldType", "fieldName": "name"}}}},
                                                                                                        "argument": {"variable": "right"}}}}}}}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"literal": "boolean"}}},
                                                                                                        "type": {"literal": "boolean"}}},
                                                                                                    "argument": {
                                                                                                      "lambda": {
                                                                                                        "parameter": "acc",
                                                                                                        "domain": {"literal": "boolean"},
                                                                                                        "body": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "x",
                                                                                                            "domain": {"literal": "boolean"},
                                                                                                            "body": {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "hydra.core.lib.logic.and"}, "argument": {"variable": "acc"}}},
                                                                                                                "argument": {"variable": "x"}}}}}}}}},
                                                                                                "argument": {"literal": {"boolean": true}}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.zipWith"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "type": {"literal": "boolean"}}},
                                                                                                        "argument": {
                                                                                                          "lambda": {
                                                                                                            "parameter": "left",
                                                                                                            "domain": {"variable": "hydra.core.model.Name"},
                                                                                                            "body": {
                                                                                                              "lambda": {
                                                                                                                "parameter": "right",
                                                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                                                "body": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": "string"}}},
                                                                                                                        "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "left"}}}}},
                                                                                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "right"}}}}}}}}}}},
                                                                                                    "argument": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {
                                                                                                              "typeApplication": {
                                                                                                                "body": {
                                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.FieldType"}}},
                                                                                                                "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "argument": {"project": {"typeName": "hydra.core.model.FieldType", "fieldName": "name"}}}},
                                                                                                        "argument": {"variable": "left"}}}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.FieldType"}}},
                                                                                                            "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                        "argument": {"project": {"typeName": "hydra.core.model.FieldType", "fieldName": "name"}}}},
                                                                                                    "argument": {"variable": "right"}}}}}}}}}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {"variable": "joinList"},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.FieldType"}}},
                                                                                                    "type": {"variable": "hydra.core.model.Type"}}},
                                                                                                "argument": {"project": {"typeName": "hydra.core.model.FieldType", "fieldName": "type"}}}},
                                                                                            "argument": {"variable": "left"}}}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.FieldType"}}},
                                                                                                "type": {"variable": "hydra.core.model.Type"}}},
                                                                                            "argument": {"project": {"typeName": "hydra.core.model.FieldType", "fieldName": "type"}}}},
                                                                                        "argument": {"variable": "right"}}}}}}},
                                                                            "argument": {
                                                                              "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}}}},
                                                                "typeScheme": {
                                                                  "variables": [],
                                                                  "body": {
                                                                    "function": {
                                                                      "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                      "codomain": {
                                                                        "function": {
                                                                          "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                          "codomain": {
                                                                            "either": {
                                                                              "left": {"variable": "hydra.core.errors.UnificationError"},
                                                                              "right": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}},
                                                                  "constraints": []}}],
                                                            "body": {
                                                              "application": {
                                                                "function": {
                                                                  "cases": {
                                                                    "typeName": "hydra.core.model.Type",
                                                                    "default": {
                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                    "cases": [
                                                                      {
                                                                        "name": "application",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.ApplicationType"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "application",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.ApplicationType"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.ApplicationType", "fieldName": "function"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.ApplicationType", "fieldName": "function"}},
                                                                                                                    "argument": {"variable": "r"}}}}},
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.ApplicationType", "fieldName": "argument"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.ApplicationType", "fieldName": "argument"}},
                                                                                                                    "argument": {"variable": "r"}}}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "either",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.EitherType"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "either",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.EitherType"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.EitherType", "fieldName": "left"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.EitherType", "fieldName": "left"}},
                                                                                                                    "argument": {"variable": "r"}}}}},
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.EitherType", "fieldName": "right"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.EitherType", "fieldName": "right"}},
                                                                                                                    "argument": {"variable": "r"}}}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "effect",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "effect",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "joinOne"}, "argument": {"variable": "l"}}},
                                                                                                                "argument": {"variable": "r"}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "function",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.FunctionType"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "function",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.FunctionType"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.FunctionType", "fieldName": "domain"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.FunctionType", "fieldName": "domain"}},
                                                                                                                    "argument": {"variable": "r"}}}}},
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.FunctionType", "fieldName": "codomain"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.FunctionType", "fieldName": "codomain"}},
                                                                                                                    "argument": {"variable": "r"}}}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "list",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "list",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "joinOne"}, "argument": {"variable": "l"}}},
                                                                                                                "argument": {"variable": "r"}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "literal",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "_",
                                                                            "domain": {"variable": "hydra.core.model.LiteralType"},
                                                                            "body": {"typeApplication": {"body": {"variable": "assertEqual"}, "type": {"variable": "hydra.core.typing.TypeConstraint"}}}}}},
                                                                      {
                                                                        "name": "map",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.MapType"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "map",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.MapType"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {"function": {"project": {"typeName": "hydra.core.model.MapType", "fieldName": "keys"}}, "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {"function": {"project": {"typeName": "hydra.core.model.MapType", "fieldName": "keys"}}, "argument": {"variable": "r"}}}}},
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.MapType", "fieldName": "values"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.MapType", "fieldName": "values"}},
                                                                                                                    "argument": {"variable": "r"}}}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "optional",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "optional",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "joinOne"}, "argument": {"variable": "l"}}},
                                                                                                                "argument": {"variable": "r"}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "pair",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.PairType"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "pair",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.PairType"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.PairType", "fieldName": "first"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.PairType", "fieldName": "first"}},
                                                                                                                    "argument": {"variable": "r"}}}}},
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {
                                                                                                                  "application": {
                                                                                                                    "function": {"variable": "joinOne"},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {"project": {"typeName": "hydra.core.model.PairType", "fieldName": "second"}},
                                                                                                                        "argument": {"variable": "l"}}}}},
                                                                                                                "argument": {
                                                                                                                  "application": {
                                                                                                                    "function": {"project": {"typeName": "hydra.core.model.PairType", "fieldName": "second"}},
                                                                                                                    "argument": {"variable": "r"}}}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "record",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "record",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "joinRowTypes"}, "argument": {"variable": "l"}}},
                                                                                                "argument": {"variable": "r"}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "set",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "set",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "joinOne"}, "argument": {"variable": "l"}}},
                                                                                                                "argument": {"variable": "r"}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "union",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "union",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "joinRowTypes"}, "argument": {"variable": "l"}}},
                                                                                                "argument": {"variable": "r"}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "unit",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "_",
                                                                            "domain": "unit",
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "unit",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "_",
                                                                                            "domain": "unit",
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {"right": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.typing.TypeConstraint"}}}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "void",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "_",
                                                                            "domain": "unit",
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "void",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "_",
                                                                                            "domain": "unit",
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {"right": {"typeApplication": {"body": {"list": []}, "type": {"variable": "hydra.core.typing.TypeConstraint"}}}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}},
                                                                      {
                                                                        "name": "wrap",
                                                                        "handler": {
                                                                          "lambda": {
                                                                            "parameter": "l",
                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {
                                                                                      "typeApplication": {"body": {"variable": "cannotUnify"}, "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "wrap",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "r",
                                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "either": {
                                                                                                        "right": {
                                                                                                          "list": [
                                                                                                            {
                                                                                                              "application": {
                                                                                                                "function": {"application": {"function": {"variable": "joinOne"}, "argument": {"variable": "l"}}},
                                                                                                                "argument": {"variable": "r"}}}]}}},
                                                                                                    "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}}}]}},
                                                                                "argument": {"variable": "sright"}}}}}}]}},
                                                                "argument": {"variable": "sleft"}}}}}}}}}}}}}}}}}}}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {
                        "literal": {
                          "string": "Join two types, producing a list of type constraints.The comment is used to provide context for the constraints."}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.unification.unifyTypeConstraints",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "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.typing.TypeConstraint"}}, "isLazy": false}],
          "result": {
            "type": {
              "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "cx",
                    "domain": {"variable": "t0"},
                    "body": {
                      "lambda": {
                        "parameter": "schemaTypes",
                        "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                        "body": {
                          "lambda": {
                            "parameter": "constraints",
                            "domain": {"list": {"variable": "hydra.core.typing.TypeConstraint"}},
                            "body": {
                              "let": {
                                "bindings": [
                                  {
                                    "name": "withConstraint",
                                    "term": {
                                      "lambda": {
                                        "parameter": "c",
                                        "domain": {"variable": "hydra.core.typing.TypeConstraint"},
                                        "body": {
                                          "lambda": {
                                            "parameter": "rest",
                                            "domain": {"list": {"variable": "hydra.core.typing.TypeConstraint"}},
                                            "body": {
                                              "let": {
                                                "bindings": [
                                                  {
                                                    "name": "sleft",
                                                    "term": {
                                                      "application": {
                                                        "function": {"variable": "hydra.core.strip.deannotateType"},
                                                        "argument": {
                                                          "application": {
                                                            "function": {"project": {"typeName": "hydra.core.typing.TypeConstraint", "fieldName": "left"}},
                                                            "argument": {"variable": "c"}}}}},
                                                    "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                                                "body": {
                                                  "let": {
                                                    "bindings": [
                                                      {
                                                        "name": "sright",
                                                        "term": {
                                                          "application": {
                                                            "function": {"variable": "hydra.core.strip.deannotateType"},
                                                            "argument": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.typing.TypeConstraint", "fieldName": "right"}},
                                                                "argument": {"variable": "c"}}}}},
                                                        "typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Type"}, "constraints": []}}],
                                                    "body": {
                                                      "let": {
                                                        "bindings": [
                                                          {
                                                            "name": "comment",
                                                            "term": {
                                                              "application": {
                                                                "function": {"project": {"typeName": "hydra.core.typing.TypeConstraint", "fieldName": "comment"}},
                                                                "argument": {"variable": "c"}}},
                                                            "typeScheme": {"variables": [], "body": {"literal": "string"}, "constraints": []}}],
                                                        "body": {
                                                          "let": {
                                                            "bindings": [
                                                              {
                                                                "name": "bind",
                                                                "term": {
                                                                  "lambda": {
                                                                    "parameter": "v",
                                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                                    "body": {
                                                                      "lambda": {
                                                                        "parameter": "t",
                                                                        "domain": {"variable": "hydra.core.model.Type"},
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "subst",
                                                                                "term": {
                                                                                  "application": {
                                                                                    "function": {"application": {"function": {"variable": "hydra.core.substitution.singletonTypeSubst"}, "argument": {"variable": "v"}}},
                                                                                    "argument": {"variable": "t"}}},
                                                                                "typeScheme": {"variables": [], "body": {"variable": "hydra.core.typing.TypeSubst"}, "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "withResult",
                                                                                    "term": {
                                                                                      "lambda": {
                                                                                        "parameter": "s",
                                                                                        "domain": {"variable": "hydra.core.typing.TypeSubst"},
                                                                                        "body": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {"function": {"variable": "hydra.core.substitution.composeTypeSubst"}, "argument": {"variable": "subst"}}},
                                                                                            "argument": {"variable": "s"}}}}},
                                                                                    "typeScheme": {
                                                                                      "variables": [],
                                                                                      "body": {
                                                                                        "function": {"domain": {"variable": "hydra.core.typing.TypeSubst"}, "codomain": {"variable": "hydra.core.typing.TypeSubst"}}},
                                                                                      "constraints": []}}],
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.map"}, "type": {"variable": "hydra.core.typing.TypeSubst"}}},
                                                                                                "type": {"variable": "hydra.core.typing.TypeSubst"}}},
                                                                                            "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                        "argument": {"variable": "withResult"}}},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {
                                                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.unification.unifyTypeConstraints"}, "type": {"variable": "t0"}}},
                                                                                                "argument": {"variable": "cx"}}},
                                                                                            "argument": {"variable": "schemaTypes"}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {"function": {"variable": "hydra.core.substitution.substituteInConstraints"}, "argument": {"variable": "subst"}}},
                                                                                            "argument": {"variable": "rest"}}}}}}}}}}}}}}},
                                                                "typeScheme": {
                                                                  "variables": [],
                                                                  "body": {
                                                                    "function": {
                                                                      "domain": {"variable": "hydra.core.model.Name"},
                                                                      "codomain": {
                                                                        "function": {
                                                                          "domain": {"variable": "hydra.core.model.Type"},
                                                                          "codomain": {
                                                                            "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}}}},
                                                                  "constraints": []}}],
                                                            "body": {
                                                              "let": {
                                                                "bindings": [
                                                                  {
                                                                    "name": "tryBinding",
                                                                    "term": {
                                                                      "lambda": {
                                                                        "parameter": "v",
                                                                        "domain": {"variable": "hydra.core.model.Name"},
                                                                        "body": {
                                                                          "lambda": {
                                                                            "parameter": "t",
                                                                            "domain": {"variable": "hydra.core.model.Type"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "typeApplication": {
                                                                                            "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                            "type": {
                                                                                              "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                        "argument": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "application": {"function": {"variable": "hydra.core.unification.variableOccursInType"}, "argument": {"variable": "v"}}},
                                                                                            "argument": {"variable": "t"}}}}},
                                                                                    "argument": {
                                                                                      "typeApplication": {
                                                                                        "body": {
                                                                                          "typeApplication": {
                                                                                            "body": {
                                                                                              "either": {
                                                                                                "left": {
                                                                                                  "record": {
                                                                                                    "typeName": "hydra.core.errors.UnificationError",
                                                                                                    "fields": [
                                                                                                      {"name": "leftType", "term": {"variable": "sleft"}},
                                                                                                      {"name": "rightType", "term": {"variable": "sright"}},
                                                                                                      {
                                                                                                        "name": "message",
                                                                                                        "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": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "application": {
                                                                                                                                                "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                                                                                                                "argument": {
                                                                                                                                                  "application": {
                                                                                                                                                    "function": {
                                                                                                                                                      "application": {"function": {"variable": "hydra.core.lib.strings.concat2"}, "argument": {"literal": {"string": "Variable "}}}},
                                                                                                                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "v"}}}}}}},
                                                                                                                                            "argument": {"literal": {"string": " appears free in type "}}}}}},
                                                                                                                                    "argument": {"application": {"function": {"variable": "hydra.core.print.model.type"}, "argument": {"variable": "t"}}}}}}},
                                                                                                                            "argument": {"literal": {"string": " ("}}}}}},
                                                                                                                    "argument": {"variable": "comment"}}}}},
                                                                                                            "argument": {"literal": {"string": ")"}}}}}]}}}},
                                                                                            "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                        "type": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {"application": {"function": {"variable": "bind"}, "argument": {"variable": "v"}}},
                                                                                    "argument": {"variable": "t"}}}}}}}}},
                                                                    "typeScheme": {
                                                                      "variables": [],
                                                                      "body": {
                                                                        "function": {
                                                                          "domain": {"variable": "hydra.core.model.Name"},
                                                                          "codomain": {
                                                                            "function": {
                                                                              "domain": {"variable": "hydra.core.model.Type"},
                                                                              "codomain": {
                                                                                "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}}}},
                                                                      "constraints": []}}],
                                                                "body": {
                                                                  "let": {
                                                                    "bindings": [
                                                                      {
                                                                        "name": "isNominalSchemaType",
                                                                        "term": {
                                                                          "lambda": {
                                                                            "parameter": "ts",
                                                                            "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                            "body": {
                                                                              "application": {
                                                                                "function": {
                                                                                  "cases": {
                                                                                    "typeName": "hydra.core.model.Type",
                                                                                    "default": {"literal": {"boolean": false}},
                                                                                    "cases": [
                                                                                      {
                                                                                        "name": "record",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "_",
                                                                                            "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                                            "body": {"literal": {"boolean": true}}}}},
                                                                                      {
                                                                                        "name": "union",
                                                                                        "handler": {
                                                                                          "lambda": {
                                                                                            "parameter": "_",
                                                                                            "domain": {"list": {"variable": "hydra.core.model.FieldType"}},
                                                                                            "body": {"literal": {"boolean": true}}}}},
                                                                                      {
                                                                                        "name": "wrap",
                                                                                        "handler": {"lambda": {"parameter": "_", "domain": {"variable": "hydra.core.model.Type"}, "body": {"literal": {"boolean": true}}}}}]}},
                                                                                "argument": {
                                                                                  "application": {
                                                                                    "function": {"variable": "hydra.core.strip.deannotateType"},
                                                                                    "argument": {
                                                                                      "application": {
                                                                                        "function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
                                                                                        "argument": {"variable": "ts"}}}}}}}}},
                                                                        "typeScheme": {
                                                                          "variables": [],
                                                                          "body": {"function": {"domain": {"variable": "hydra.core.model.TypeScheme"}, "codomain": {"literal": "boolean"}}},
                                                                          "constraints": []}}],
                                                                    "body": {
                                                                      "let": {
                                                                        "bindings": [
                                                                          {
                                                                            "name": "tryBindOrSchema",
                                                                            "term": {
                                                                              "lambda": {
                                                                                "parameter": "v",
                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                "body": {
                                                                                  "lambda": {
                                                                                    "parameter": "t",
                                                                                    "domain": {"variable": "hydra.core.model.Type"},
                                                                                    "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.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
                                                                                                            "type": {"variable": "hydra.core.model.TypeScheme"}}},
                                                                                                        "argument": {"variable": "v"}}},
                                                                                                    "argument": {"variable": "schemaTypes"}}}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {"application": {"function": {"variable": "tryBinding"}, "argument": {"variable": "v"}}},
                                                                                                "argument": {"variable": "t"}}}}},
                                                                                        "argument": {
                                                                                          "lambda": {
                                                                                            "parameter": "ts",
                                                                                            "domain": {"variable": "hydra.core.model.TypeScheme"},
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                            "type": {
                                                                                                              "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                                        "argument": {"application": {"function": {"variable": "isNominalSchemaType"}, "argument": {"variable": "ts"}}}}},
                                                                                                    "argument": {
                                                                                                      "typeApplication": {
                                                                                                        "body": {
                                                                                                          "typeApplication": {
                                                                                                            "body": {
                                                                                                              "either": {
                                                                                                                "left": {
                                                                                                                  "record": {
                                                                                                                    "typeName": "hydra.core.errors.UnificationError",
                                                                                                                    "fields": [
                                                                                                                      {"name": "leftType", "term": {"variable": "sleft"}},
                                                                                                                      {"name": "rightType", "term": {"variable": "sright"}},
                                                                                                                      {
                                                                                                                        "name": "message",
                                                                                                                        "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": {
                                                                                                                                                          "application": {
                                                                                                                                                            "function": {
                                                                                                                                                              "application": {
                                                                                                                                                                "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                                                                                                                                "argument": {
                                                                                                                                                                  "application": {
                                                                                                                                                                    "function": {
                                                                                                                                                                      "application": {
                                                                                                                                                                        "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                                                                                                                                        "argument": {"literal": {"string": "Cannot unify schema name "}}}},
                                                                                                                                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "v"}}}}}}},
                                                                                                                                                            "argument": {"literal": {"string": " with type "}}}}}},
                                                                                                                                                    "argument": {"application": {"function": {"variable": "hydra.core.print.model.type"}, "argument": {"variable": "t"}}}}}}},
                                                                                                                                            "argument": {"literal": {"string": " ("}}}}}},
                                                                                                                                    "argument": {"variable": "comment"}}}}},
                                                                                                                            "argument": {"literal": {"string": ")"}}}}}]}}}},
                                                                                                            "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                        "type": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {"application": {"function": {"variable": "tryBinding"}, "argument": {"variable": "v"}}},
                                                                                                    "argument": {"variable": "t"}}}}}}}}}}}}},
                                                                            "typeScheme": {
                                                                              "variables": [],
                                                                              "body": {
                                                                                "function": {
                                                                                  "domain": {"variable": "hydra.core.model.Name"},
                                                                                  "codomain": {
                                                                                    "function": {
                                                                                      "domain": {"variable": "hydra.core.model.Type"},
                                                                                      "codomain": {
                                                                                        "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}}}},
                                                                              "constraints": []}}],
                                                                        "body": {
                                                                          "let": {
                                                                            "bindings": [
                                                                              {
                                                                                "name": "noVars",
                                                                                "term": {
                                                                                  "let": {
                                                                                    "bindings": [
                                                                                      {
                                                                                        "name": "withConstraints",
                                                                                        "term": {
                                                                                          "lambda": {
                                                                                            "parameter": "constraints2",
                                                                                            "domain": {"list": {"variable": "hydra.core.typing.TypeConstraint"}},
                                                                                            "body": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.unification.unifyTypeConstraints"}, "type": {"variable": "t0"}}},
                                                                                                        "argument": {"variable": "cx"}}},
                                                                                                    "argument": {"variable": "schemaTypes"}}},
                                                                                                "argument": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.lists.concat2"}, "type": {"variable": "hydra.core.typing.TypeConstraint"}}},
                                                                                                        "argument": {"variable": "constraints2"}}},
                                                                                                    "argument": {"variable": "rest"}}}}}}},
                                                                                        "typeScheme": {
                                                                                          "variables": [],
                                                                                          "body": {
                                                                                            "function": {
                                                                                              "domain": {"list": {"variable": "hydra.core.typing.TypeConstraint"}},
                                                                                              "codomain": {
                                                                                                "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                          "constraints": []}}],
                                                                                    "body": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "application": {
                                                                                            "function": {
                                                                                              "typeApplication": {
                                                                                                "body": {
                                                                                                  "typeApplication": {
                                                                                                    "body": {
                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.eithers.bind"}, "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                    "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                                                                "type": {"variable": "hydra.core.typing.TypeSubst"}}},
                                                                                            "argument": {
                                                                                              "application": {
                                                                                                "function": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "application": {
                                                                                                        "function": {
                                                                                                          "application": {
                                                                                                            "function": {"typeApplication": {"body": {"variable": "hydra.core.unification.joinTypes"}, "type": {"variable": "t0"}}},
                                                                                                            "argument": {"variable": "cx"}}},
                                                                                                        "argument": {"variable": "sleft"}}},
                                                                                                    "argument": {"variable": "sright"}}},
                                                                                                "argument": {"variable": "comment"}}}}},
                                                                                        "argument": {"variable": "withConstraints"}}}}},
                                                                                "typeScheme": {
                                                                                  "variables": [],
                                                                                  "body": {
                                                                                    "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}},
                                                                                  "constraints": []}}],
                                                                            "body": {
                                                                              "let": {
                                                                                "bindings": [
                                                                                  {
                                                                                    "name": "dflt",
                                                                                    "term": {
                                                                                      "application": {
                                                                                        "function": {
                                                                                          "cases": {
                                                                                            "typeName": "hydra.core.model.Type",
                                                                                            "default": {"variable": "noVars"},
                                                                                            "cases": [
                                                                                              {
                                                                                                "name": "variable",
                                                                                                "handler": {
                                                                                                  "lambda": {
                                                                                                    "parameter": "name",
                                                                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                                                                    "body": {
                                                                                                      "application": {
                                                                                                        "function": {"application": {"function": {"variable": "tryBindOrSchema"}, "argument": {"variable": "name"}}},
                                                                                                        "argument": {"variable": "sleft"}}}}}}]}},
                                                                                        "argument": {"variable": "sright"}}},
                                                                                    "typeScheme": {
                                                                                      "variables": [],
                                                                                      "body": {
                                                                                        "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}},
                                                                                      "constraints": []}}],
                                                                                "body": {
                                                                                  "application": {
                                                                                    "function": {
                                                                                      "cases": {
                                                                                        "typeName": "hydra.core.model.Type",
                                                                                        "default": {"variable": "dflt"},
                                                                                        "cases": [
                                                                                          {
                                                                                            "name": "variable",
                                                                                            "handler": {
                                                                                              "lambda": {
                                                                                                "parameter": "name",
                                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                                "body": {
                                                                                                  "application": {
                                                                                                    "function": {
                                                                                                      "cases": {
                                                                                                        "typeName": "hydra.core.model.Type",
                                                                                                        "default": {
                                                                                                          "application": {
                                                                                                            "function": {"application": {"function": {"variable": "tryBindOrSchema"}, "argument": {"variable": "name"}}},
                                                                                                            "argument": {"variable": "sright"}}},
                                                                                                        "cases": [
                                                                                                          {
                                                                                                            "name": "variable",
                                                                                                            "handler": {
                                                                                                              "lambda": {
                                                                                                                "parameter": "name2",
                                                                                                                "domain": {"variable": "hydra.core.model.Name"},
                                                                                                                "body": {
                                                                                                                  "application": {
                                                                                                                    "function": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "typeApplication": {
                                                                                                                                "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                                "type": {
                                                                                                                                  "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": "string"}}},
                                                                                                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "name"}}}}},
                                                                                                                                "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "name2"}}}}}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.unification.unifyTypeConstraints"}, "type": {"variable": "t0"}}},
                                                                                                                                    "argument": {"variable": "cx"}}},
                                                                                                                                "argument": {"variable": "schemaTypes"}}},
                                                                                                                            "argument": {"variable": "rest"}}}}},
                                                                                                                    "argument": {
                                                                                                                      "application": {
                                                                                                                        "function": {
                                                                                                                          "application": {
                                                                                                                            "function": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "typeApplication": {
                                                                                                                                    "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                                    "type": {
                                                                                                                                      "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.isGiven"}, "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": "schemaTypes"}}}}}}},
                                                                                                                            "argument": {
                                                                                                                              "application": {
                                                                                                                                "function": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {
                                                                                                                                      "application": {
                                                                                                                                        "function": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {"variable": "hydra.core.lib.logic.ifElse"},
                                                                                                                                            "type": {
                                                                                                                                              "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                                                                        "argument": {
                                                                                                                                          "application": {
                                                                                                                                            "function": {
                                                                                                                                              "typeApplication": {"body": {"variable": "hydra.core.lib.optionals.isGiven"}, "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": "name2"}}},
                                                                                                                                                "argument": {"variable": "schemaTypes"}}}}}}},
                                                                                                                                    "argument": {
                                                                                                                                      "typeApplication": {
                                                                                                                                        "body": {
                                                                                                                                          "typeApplication": {
                                                                                                                                            "body": {
                                                                                                                                              "either": {
                                                                                                                                                "left": {
                                                                                                                                                  "record": {
                                                                                                                                                    "typeName": "hydra.core.errors.UnificationError",
                                                                                                                                                    "fields": [
                                                                                                                                                      {"name": "leftType", "term": {"variable": "sleft"}},
                                                                                                                                                      {"name": "rightType", "term": {"variable": "sright"}},
                                                                                                                                                      {
                                                                                                                                                        "name": "message",
                                                                                                                                                        "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": {
                                                                                                                                                                                          "application": {
                                                                                                                                                                                            "function": {
                                                                                                                                                                                              "application": {
                                                                                                                                                                                                "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                                                                                                                                                                "argument": {
                                                                                                                                                                                                  "application": {
                                                                                                                                                                                                    "function": {
                                                                                                                                                                                                      "application": {
                                                                                                                                                                                                        "function": {"variable": "hydra.core.lib.strings.concat2"},
                                                                                                                                                                                                        "argument": {"literal": {"string": "Attempted to unify schema names "}}}},
                                                                                                                                                                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "name"}}}}}}},
                                                                                                                                                                                            "argument": {"literal": {"string": " and "}}}}}},
                                                                                                                                                                                    "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "name2"}}}}}}},
                                                                                                                                                                            "argument": {"literal": {"string": " ("}}}}}},
                                                                                                                                                                    "argument": {"variable": "comment"}}}}},
                                                                                                                                                            "argument": {"literal": {"string": ")"}}}}}]}}}},
                                                                                                                                            "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                                                                                                                        "type": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                                                                                                                "argument": {
                                                                                                                                  "application": {
                                                                                                                                    "function": {"application": {"function": {"variable": "bind"}, "argument": {"variable": "name2"}}},
                                                                                                                                    "argument": {"variable": "sleft"}}}}}}},
                                                                                                                        "argument": {
                                                                                                                          "application": {
                                                                                                                            "function": {"application": {"function": {"variable": "bind"}, "argument": {"variable": "name"}}},
                                                                                                                            "argument": {"variable": "sright"}}}}}}}}}}]}},
                                                                                                    "argument": {"variable": "sright"}}}}}}]}},
                                                                                    "argument": {"variable": "sleft"}}}}}}}}}}}}}}}}}}}}}}}}},
                                    "typeScheme": {
                                      "variables": [],
                                      "body": {
                                        "function": {
                                          "domain": {"variable": "hydra.core.typing.TypeConstraint"},
                                          "codomain": {
                                            "function": {
                                              "domain": {"list": {"variable": "hydra.core.typing.TypeConstraint"}},
                                              "codomain": {
                                                "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}}}},
                                      "constraints": []}}],
                                "body": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "typeApplication": {
                                                "body": {
                                                  "typeApplication": {
                                                    "body": {"variable": "hydra.core.lib.optionals.match"},
                                                    "type": {
                                                      "pair": {
                                                        "first": {"variable": "hydra.core.typing.TypeConstraint"},
                                                        "second": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}}}},
                                                "type": {
                                                  "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.uncons"}, "type": {"variable": "hydra.core.typing.TypeConstraint"}}},
                                                "argument": {"variable": "constraints"}}}}},
                                        "argument": {
                                          "typeApplication": {
                                            "body": {
                                              "typeApplication": {
                                                "body": {"either": {"right": {"variable": "hydra.core.substitution.idTypeSubst"}}},
                                                "type": {"variable": "hydra.core.errors.UnificationError"}}},
                                            "type": {"variable": "hydra.core.typing.TypeSubst"}}}}},
                                    "argument": {
                                      "lambda": {
                                        "parameter": "uc",
                                        "domain": {
                                          "pair": {
                                            "first": {"variable": "hydra.core.typing.TypeConstraint"},
                                            "second": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                        "body": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {"variable": "withConstraint"},
                                                "argument": {
                                                  "application": {
                                                    "function": {
                                                      "typeApplication": {
                                                        "body": {
                                                          "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.typing.TypeConstraint"}}},
                                                        "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                    "argument": {"variable": "uc"}}}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "typeApplication": {
                                                    "body": {
                                                      "typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.typing.TypeConstraint"}}},
                                                    "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
                                                "argument": {"variable": "uc"}}}}}}}}}}}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {
                        "literal": {
                          "string": "Robinson's algorithm, following https://www.cs.cornell.edu/courses/cs6110/2017sp/lectures/lec23.pdf\nSpecifically this is an implementation of the following rules:\n  * Unify({(x, t)} ∪ E) = {t/x} Unify(E{t/x}) if x ∉ FV(t)\n  * Unify(∅) = I (the identity substitution x ↦ x)\n  * Unify({(x, x)} ∪ E) = Unify(E)\n  * Unify({(f(s1, ..., sn), f(t1, ..., tn))} ∪ E) = Unify({(s1, t1), ..., (sn, tn)} ∪ E))"}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.unification.unifyTypeLists",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "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.Type"}}, "isLazy": false},
            {"name": "arg3", "type": {"list": {"variable": "hydra.core.model.Type"}}, "isLazy": false},
            {"name": "arg4", "type": {"literal": "string"}, "isLazy": false}],
          "result": {
            "type": {
              "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "cx",
                    "domain": {"variable": "t0"},
                    "body": {
                      "lambda": {
                        "parameter": "schemaTypes",
                        "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                        "body": {
                          "lambda": {
                            "parameter": "l",
                            "domain": {"list": {"variable": "hydra.core.model.Type"}},
                            "body": {
                              "lambda": {
                                "parameter": "r",
                                "domain": {"list": {"variable": "hydra.core.model.Type"}},
                                "body": {
                                  "lambda": {
                                    "parameter": "comment",
                                    "domain": {"literal": "string"},
                                    "body": {
                                      "let": {
                                        "bindings": [
                                          {
                                            "name": "toConstraint",
                                            "term": {
                                              "lambda": {
                                                "parameter": "l",
                                                "domain": {"variable": "hydra.core.model.Type"},
                                                "body": {
                                                  "lambda": {
                                                    "parameter": "r",
                                                    "domain": {"variable": "hydra.core.model.Type"},
                                                    "body": {
                                                      "record": {
                                                        "typeName": "hydra.core.typing.TypeConstraint",
                                                        "fields": [
                                                          {"name": "left", "term": {"variable": "l"}},
                                                          {"name": "right", "term": {"variable": "r"}},
                                                          {"name": "comment", "term": {"variable": "comment"}}]}}}}}},
                                            "typeScheme": {
                                              "variables": [],
                                              "body": {
                                                "function": {
                                                  "domain": {"variable": "hydra.core.model.Type"},
                                                  "codomain": {
                                                    "function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.typing.TypeConstraint"}}}}},
                                              "constraints": []}}],
                                        "body": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {"typeApplication": {"body": {"variable": "hydra.core.unification.unifyTypeConstraints"}, "type": {"variable": "t0"}}},
                                                    "argument": {"variable": "cx"}}},
                                                "argument": {"variable": "schemaTypes"}}},
                                            "argument": {
                                              "application": {
                                                "function": {
                                                  "application": {
                                                    "function": {
                                                      "application": {
                                                        "function": {
                                                          "typeApplication": {
                                                            "body": {
                                                              "typeApplication": {
                                                                "body": {
                                                                  "typeApplication": {"body": {"variable": "hydra.core.lib.lists.zipWith"}, "type": {"variable": "hydra.core.model.Type"}}},
                                                                "type": {"variable": "hydra.core.model.Type"}}},
                                                            "type": {"variable": "hydra.core.typing.TypeConstraint"}}},
                                                        "argument": {"variable": "toConstraint"}}},
                                                    "argument": {"variable": "l"}}},
                                                "argument": {"variable": "r"}}}}}}}}}}}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {
                        "literal": {
                          "string": "Unify two lists of types pairwise, producing a single substitution that satisfies every pair. The lists must have the same length; the comment is attached to each generated constraint for diagnostics."}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.unification.unifyTypes",
        "signature": {
          "typeParameters": [{"name": "t0", "constraints": []}],
          "parameters": [
            {"name": "arg0", "type": {"variable": "t0"}, "isLazy": false},
            {
              "name": "arg1",
              "type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
              "isLazy": false},
            {"name": "arg2", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false},
            {"name": "arg3", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false},
            {"name": "arg4", "type": {"literal": "string"}, "isLazy": false}],
          "result": {
            "type": {
              "either": {"left": {"variable": "hydra.core.errors.UnificationError"}, "right": {"variable": "hydra.core.typing.TypeSubst"}}}}},
        "body": {
          "typeLambda": {
            "parameter": "t0",
            "body": {
              "annotated": {
                "body": {
                  "lambda": {
                    "parameter": "cx",
                    "domain": {"variable": "t0"},
                    "body": {
                      "lambda": {
                        "parameter": "schemaTypes",
                        "domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
                        "body": {
                          "lambda": {
                            "parameter": "l",
                            "domain": {"variable": "hydra.core.model.Type"},
                            "body": {
                              "lambda": {
                                "parameter": "r",
                                "domain": {"variable": "hydra.core.model.Type"},
                                "body": {
                                  "lambda": {
                                    "parameter": "comment",
                                    "domain": {"literal": "string"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "application": {
                                            "function": {
                                              "application": {
                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.unification.unifyTypeConstraints"}, "type": {"variable": "t0"}}},
                                                "argument": {"variable": "cx"}}},
                                            "argument": {"variable": "schemaTypes"}}},
                                        "argument": {
                                          "list": [
                                            {
                                              "record": {
                                                "typeName": "hydra.core.typing.TypeConstraint",
                                                "fields": [
                                                  {"name": "left", "term": {"variable": "l"}},
                                                  {"name": "right", "term": {"variable": "r"}},
                                                  {"name": "comment", "term": {"variable": "comment"}}]}}]}}}}}}}}}}}}},
                "annotation": {
                  "map": [
                    {
                      "key": {"variable": "description"},
                      "value": {
                        "literal": {
                          "string": "Unify two types, producing a substitution that makes them equal (or an error). The comment is attached to the generated constraint for diagnostics."}}}]}}}}}}},
    {
      "term": {
        "name": "hydra.core.unification.variableOccursInType",
        "signature": {
          "typeParameters": [],
          "parameters": [
            {"name": "arg0", "type": {"variable": "hydra.core.model.Name"}, "isLazy": false},
            {"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
          "result": {"type": {"literal": "boolean"}}},
        "body": {
          "annotated": {
            "body": {
              "lambda": {
                "parameter": "var",
                "domain": {"variable": "hydra.core.model.Name"},
                "body": {
                  "lambda": {
                    "parameter": "typ0",
                    "domain": {"variable": "hydra.core.model.Type"},
                    "body": {
                      "let": {
                        "bindings": [
                          {
                            "name": "tryType",
                            "term": {
                              "lambda": {
                                "parameter": "b",
                                "domain": {"literal": "boolean"},
                                "body": {
                                  "lambda": {
                                    "parameter": "typ",
                                    "domain": {"variable": "hydra.core.model.Type"},
                                    "body": {
                                      "application": {
                                        "function": {
                                          "cases": {
                                            "typeName": "hydra.core.model.Type",
                                            "default": {"variable": "b"},
                                            "cases": [
                                              {
                                                "name": "variable",
                                                "handler": {
                                                  "lambda": {
                                                    "parameter": "v",
                                                    "domain": {"variable": "hydra.core.model.Name"},
                                                    "body": {
                                                      "application": {
                                                        "function": {"application": {"function": {"variable": "hydra.core.lib.logic.or"}, "argument": {"variable": "b"}}},
                                                        "argument": {
                                                          "application": {
                                                            "function": {
                                                              "application": {
                                                                "function": {"typeApplication": {"body": {"variable": "hydra.core.lib.equality.equal"}, "type": {"literal": "string"}}},
                                                                "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "v"}}}}},
                                                            "argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "var"}}}}}}}}}}]}},
                                        "argument": {"variable": "typ"}}}}}}},
                            "typeScheme": {
                              "variables": [],
                              "body": {
                                "function": {
                                  "domain": {"literal": "boolean"},
                                  "codomain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"literal": "boolean"}}}}},
                              "constraints": []}}],
                        "body": {
                          "application": {
                            "function": {
                              "application": {
                                "function": {
                                  "application": {
                                    "function": {
                                      "application": {
                                        "function": {"typeApplication": {"body": {"variable": "hydra.core.rewriting.foldOverType"}, "type": {"literal": "boolean"}}},
                                        "argument": {"inject": {"typeName": "hydra.core.coders.TraversalOrder", "field": {"name": "pre", "term": "unit"}}}}},
                                    "argument": {"variable": "tryType"}}},
                                "argument": {"literal": {"boolean": false}}}},
                            "argument": {"variable": "typ0"}}}}}}}}},
            "annotation": {
              "map": [
                {
                  "key": {"variable": "description"},
                  "value": {
                    "literal": {
                      "string": "Determine whether a type variable appears within a type expression.No distinction is made between free and bound type variables."}}}]}}}}}]}