hydra-kernel-0.18.1: hydra-kernel-json/hydra/core/substitution.json
{
"name": "hydra.core.substitution",
"metadata": {"description": "Variable substitution in type and term expressions.", "comments": [], "seeAlso": [], "provisions": []},
"dependencies": [
{"module": "hydra.core.classes"},
{"module": "hydra.core.graph"},
{"module": "hydra.core.lib.lists"},
{"module": "hydra.core.lib.logic"},
{"module": "hydra.core.lib.maps"},
{"module": "hydra.core.lib.optionals"},
{"module": "hydra.core.lib.ordering"},
{"module": "hydra.core.lib.pairs"},
{"module": "hydra.core.lib.sets"},
{"module": "hydra.core.lib.strings"},
{"module": "hydra.core.model"},
{"module": "hydra.core.rewriting"},
{"module": "hydra.core.typing"},
{"module": "hydra.core.variables"}],
"definitions": [
{
"term": {
"name": "hydra.core.substitution.composeTypeSubst",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.typing.TypeSubst"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "s1",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "s2",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.typing.TypeSubst"}}},
"argument": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.isEmpty"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "s1"}}}}}}},
"argument": {"variable": "s2"}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.typing.TypeSubst"}}},
"argument": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.isEmpty"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "s2"}}}}}}},
"argument": {"variable": "s1"}}},
"argument": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.composeTypeSubstNonEmpty"}, "argument": {"variable": "s1"}}},
"argument": {"variable": "s2"}}}}}}}}}}},
"annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Compose two type substitutions"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.composeTypeSubstList",
"signature": {
"typeParameters": [],
"parameters": [{"name": "arg0", "type": {"list": {"variable": "hydra.core.typing.TypeSubst"}}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.typing.TypeSubst"}}},
"body": {
"annotated": {
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.lists.foldl"}, "type": {"variable": "hydra.core.typing.TypeSubst"}}},
"type": {"variable": "hydra.core.typing.TypeSubst"}}},
"argument": {"variable": "hydra.core.substitution.composeTypeSubst"}}},
"argument": {"variable": "hydra.core.substitution.idTypeSubst"}}},
"annotation": {
"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Compose a list of type substitutions"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.composeTypeSubstNonEmpty",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.typing.TypeSubst"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "s1",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "s2",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"let": {
"bindings": [
{
"name": "isExtra",
"term": {
"typeLambda": {
"parameter": "t0",
"body": {
"lambda": {
"parameter": "k",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"lambda": {
"parameter": "v",
"domain": {"variable": "t0"},
"body": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.isNone"}, "type": {"variable": "hydra.core.model.Type"}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "k"}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "s1"}}}}}}}}}}}}},
"typeScheme": {
"variables": ["t0"],
"body": {
"function": {
"domain": {"variable": "hydra.core.model.Name"},
"codomain": {"function": {"domain": {"variable": "t0"}, "codomain": {"literal": "boolean"}}}}},
"constraints": []}},
{
"name": "withExtra",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.filterWithKey"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"typeApplication": {"body": {"variable": "isExtra"}, "type": {"variable": "hydra.core.model.Type"}}}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "s2"}}}}},
"typeScheme": {
"variables": [],
"body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Type"}}},
"constraints": []}}],
"body": {
"wrap": {
"typeName": "hydra.core.typing.TypeSubst",
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.union"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "withExtra"}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.map"}, "type": {"variable": "hydra.core.model.Type"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"type": {"variable": "hydra.core.model.Name"}}},
"argument": {"application": {"function": {"variable": "hydra.core.substitution.substInType"}, "argument": {"variable": "s2"}}}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "s1"}}}}}}}}}}}}}}},
"annotation": {
"map": [
{
"key": {"variable": "description"},
"value": {"literal": {"string": "Compose two non-empty type substitutions (internal helper)"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.idTypeSubst",
"signature": {"typeParameters": [], "parameters": [], "result": {"type": {"variable": "hydra.core.typing.TypeSubst"}}},
"body": {
"annotated": {
"body": {
"wrap": {
"typeName": "hydra.core.typing.TypeSubst",
"body": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}}}},
"annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "The identity type substitution"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.singletonTypeSubst",
"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": {"variable": "hydra.core.typing.TypeSubst"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "v",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"lambda": {
"parameter": "t",
"domain": {"variable": "hydra.core.model.Type"},
"body": {
"wrap": {
"typeName": "hydra.core.typing.TypeSubst",
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.singleton"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "v"}}},
"argument": {"variable": "t"}}}}}}}}},
"annotation": {
"map": [
{
"key": {"variable": "description"},
"value": {"literal": {"string": "Create a type substitution with a single variable mapping"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substInClassConstraints",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{
"name": "arg1",
"type": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"isLazy": false}],
"result": {
"type": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "constraints",
"domain": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"body": {
"let": {
"bindings": [
{
"name": "substMap",
"term": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "subst"}}},
"typeScheme": {
"variables": [],
"body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Type"}}},
"constraints": []}}],
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"variable": "hydra.core.lib.logic.ifElse"},
"type": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"argument": {
"application": {
"function": {
"application": {
"function": {"variable": "hydra.core.lib.logic.or"},
"argument": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.isEmpty"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "substMap"}}}}},
"argument": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.isEmpty"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"argument": {"variable": "constraints"}}}}}}},
"argument": {"variable": "constraints"}}},
"argument": {
"let": {
"bindings": [
{
"name": "isGenuineVarName",
"term": {
"lambda": {
"parameter": "name",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"application": {
"function": {
"application": {
"function": {"typeApplication": {"body": {"variable": "hydra.core.lib.ordering.lte"}, "type": {"literal": {"integer": "int32"}}}},
"argument": {
"application": {
"function": {"typeApplication": {"body": {"variable": "hydra.core.lib.lists.length"}, "type": {"literal": "string"}}},
"argument": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.lib.strings.splitOn"}, "argument": {"literal": {"string": "."}}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.model.Name"}, "argument": {"variable": "name"}}}}}}}}},
"argument": {"literal": {"integer": {"int32": 1}}}}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.Name"}, "codomain": {"literal": "boolean"}}},
"constraints": []}}],
"body": {
"let": {
"bindings": [
{
"name": "insertOrMerge",
"term": {
"typeLambda": {
"parameter": "t0",
"body": {
"lambda": {
"parameter": "varName",
"domain": {"variable": "t0"},
"body": {
"lambda": {
"parameter": "metadata",
"domain": {"variable": "hydra.core.model.TypeVariableConstraints"},
"body": {
"lambda": {
"parameter": "acc",
"domain": {"map": {"keys": {"variable": "t0"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {
"body": {"variable": "hydra.core.lib.optionals.match"},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"type": {"map": {"keys": {"variable": "t0"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "t0"}}},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"argument": {"variable": "varName"}}},
"argument": {"variable": "acc"}}}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"variable": "t0"}}},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"argument": {"variable": "varName"}}},
"argument": {"variable": "metadata"}}},
"argument": {"variable": "acc"}}}}},
"argument": {
"lambda": {
"parameter": "existing",
"domain": {"variable": "hydra.core.model.TypeVariableConstraints"},
"body": {
"let": {
"bindings": [
{
"name": "merged",
"term": {
"record": {
"typeName": "hydra.core.model.TypeVariableConstraints",
"fields": [
{
"name": "classes",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.sets.union"}, "type": {"variable": "hydra.core.model.TypeClassConstraint"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeVariableConstraints", "fieldName": "classes"}},
"argument": {"variable": "existing"}}}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeVariableConstraints", "fieldName": "classes"}},
"argument": {"variable": "metadata"}}}}}}]}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.TypeVariableConstraints"}, "constraints": []}}],
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.insert"}, "type": {"variable": "t0"}}},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"argument": {"variable": "varName"}}},
"argument": {"variable": "merged"}}},
"argument": {"variable": "acc"}}}}}}}}}}}}}}}}},
"typeScheme": {
"variables": ["t0"],
"body": {
"function": {
"domain": {"variable": "t0"},
"codomain": {
"function": {
"domain": {"variable": "hydra.core.model.TypeVariableConstraints"},
"codomain": {
"function": {
"domain": {"map": {"keys": {"variable": "t0"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"codomain": {"map": {"keys": {"variable": "t0"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}}}}}},
"constraints": [{"key": "t0", "value": {"classes": [{"simple": "ordering"}]}}]}}],
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {
"body": {"variable": "hydra.core.lib.lists.foldl"},
"type": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"type": {
"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"argument": {
"lambda": {
"parameter": "acc",
"domain": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"body": {
"lambda": {
"parameter": "pair",
"domain": {
"pair": {"first": {"variable": "hydra.core.model.Name"}, "second": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"body": {
"let": {
"bindings": [
{
"name": "varName",
"term": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.first"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"argument": {"variable": "pair"}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}}],
"body": {
"let": {
"bindings": [
{
"name": "metadata",
"term": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.pairs.second"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"argument": {"variable": "pair"}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.TypeVariableConstraints"}, "constraints": []}}],
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
"type": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "varName"}}},
"argument": {"variable": "substMap"}}}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {"typeApplication": {"body": {"variable": "insertOrMerge"}, "type": {"variable": "hydra.core.model.Name"}}},
"argument": {"variable": "varName"}}},
"argument": {"variable": "metadata"}}},
"argument": {"variable": "acc"}}}}},
"argument": {
"lambda": {
"parameter": "targetType",
"domain": {"variable": "hydra.core.model.Type"},
"body": {
"let": {
"bindings": [
{
"name": "genuineVars",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.lists.filter"}, "type": {"variable": "hydra.core.model.Name"}}},
"argument": {"variable": "isGenuineVarName"}}},
"argument": {
"application": {
"function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
"argument": {
"application": {"function": {"variable": "hydra.core.variables.freeVariablesInType"}, "argument": {"variable": "targetType"}}}}}}},
"typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Name"}}, "constraints": []}}],
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"variable": "hydra.core.lib.logic.ifElse"},
"type": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"argument": {
"application": {
"function": {"variable": "hydra.core.lib.logic.not"},
"argument": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.lists.isEmpty"}, "type": {"variable": "hydra.core.model.Name"}}},
"argument": {"variable": "genuineVars"}}}}}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {
"body": {"variable": "hydra.core.lib.lists.foldl"},
"type": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"type": {"variable": "hydra.core.model.Name"}}},
"argument": {
"lambda": {
"parameter": "acc2",
"domain": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"body": {
"lambda": {
"parameter": "freeVar",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {"typeApplication": {"body": {"variable": "insertOrMerge"}, "type": {"variable": "hydra.core.model.Name"}}},
"argument": {"variable": "freeVar"}}},
"argument": {"variable": "metadata"}}},
"argument": {"variable": "acc2"}}}}}}}}},
"argument": {"variable": "acc"}}},
"argument": {"variable": "genuineVars"}}}}},
"argument": {
"let": {
"bindings": [
{
"name": "unsatisfied",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.sets.filter"}, "type": {"variable": "hydra.core.model.TypeClassConstraint"}}},
"argument": {
"lambda": {
"parameter": "c",
"domain": {"variable": "hydra.core.model.TypeClassConstraint"},
"body": {
"application": {
"function": {"variable": "hydra.core.lib.logic.not"},
"argument": {
"application": {
"function": {
"application": {
"function": {"variable": "hydra.core.classes.classIsSatisfiedByType"},
"argument": {
"application": {
"function": {
"cases": {
"typeName": "hydra.core.model.TypeClassConstraint",
"cases": [
{
"name": "simple",
"handler": {"lambda": {"parameter": "n", "domain": {"variable": "hydra.core.model.Name"}, "body": {"variable": "n"}}}}]}},
"argument": {"variable": "c"}}}}},
"argument": {"variable": "targetType"}}}}}}}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeVariableConstraints", "fieldName": "classes"}},
"argument": {"variable": "metadata"}}}}},
"typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.TypeClassConstraint"}}, "constraints": []}}],
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"variable": "hydra.core.lib.logic.ifElse"},
"type": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"argument": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.sets.isEmpty"}, "type": {"variable": "hydra.core.model.TypeClassConstraint"}}},
"argument": {"variable": "unsatisfied"}}}}},
"argument": {"variable": "acc"}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {"typeApplication": {"body": {"variable": "insertOrMerge"}, "type": {"variable": "hydra.core.model.Name"}}},
"argument": {"variable": "varName"}}},
"argument": {
"record": {
"typeName": "hydra.core.model.TypeVariableConstraints",
"fields": [{"name": "classes", "term": {"variable": "unsatisfied"}}]}}}},
"argument": {"variable": "acc"}}}}}}}}}}}}}}}}}}}}}}}}},
"argument": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.empty"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}}}},
"argument": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.toList"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"argument": {"variable": "constraints"}}}}}}}}}}}}}}}}},
"annotation": {
"map": [
{
"key": {"variable": "description"},
"value": {
"literal": {
"string": "Apply a type substitution to class constraints, propagating to free variables or discharging/retaining on concrete resolution"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substInContext",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.graph.Graph"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.graph.Graph"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "cx",
"domain": {"variable": "hydra.core.graph.Graph"},
"body": {
"let": {
"bindings": [
{
"name": "newBoundTypes",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
"type": {"variable": "hydra.core.model.TypeScheme"}}},
"type": {"variable": "hydra.core.model.Name"}}},
"argument": {
"application": {"function": {"variable": "hydra.core.substitution.substInTypeScheme"}, "argument": {"variable": "subst"}}}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
"argument": {"variable": "cx"}}}}},
"typeScheme": {
"variables": [],
"body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeScheme"}}},
"constraints": []}}],
"body": {
"let": {
"bindings": [
{
"name": "newClassConstraints",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substInClassConstraints"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "classConstraints"}},
"argument": {"variable": "cx"}}}}},
"typeScheme": {
"variables": [],
"body": {
"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.TypeVariableConstraints"}}},
"constraints": []}}],
"body": {
"let": {
"bindings": [
{
"name": "cx2",
"term": {
"record": {
"typeName": "hydra.core.graph.Graph",
"fields": [
{
"name": "boundTerms",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTerms"}},
"argument": {"variable": "cx"}}}},
{"name": "boundTypes", "term": {"variable": "newBoundTypes"}},
{
"name": "classConstraints",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "classConstraints"}},
"argument": {"variable": "cx"}}}},
{
"name": "lambdaVariables",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "lambdaVariables"}},
"argument": {"variable": "cx"}}}},
{
"name": "metadata",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "metadata"}},
"argument": {"variable": "cx"}}}},
{
"name": "primitives",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "primitives"}},
"argument": {"variable": "cx"}}}},
{
"name": "schemaTypes",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "schemaTypes"}},
"argument": {"variable": "cx"}}}},
{
"name": "typeVariables",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "typeVariables"}},
"argument": {"variable": "cx"}}}}]}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.graph.Graph"}, "constraints": []}}],
"body": {
"record": {
"typeName": "hydra.core.graph.Graph",
"fields": [
{
"name": "boundTerms",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTerms"}},
"argument": {"variable": "cx2"}}}},
{
"name": "boundTypes",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "boundTypes"}},
"argument": {"variable": "cx2"}}}},
{"name": "classConstraints", "term": {"variable": "newClassConstraints"}},
{
"name": "lambdaVariables",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "lambdaVariables"}},
"argument": {"variable": "cx2"}}}},
{
"name": "metadata",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "metadata"}},
"argument": {"variable": "cx2"}}}},
{
"name": "primitives",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "primitives"}},
"argument": {"variable": "cx2"}}}},
{
"name": "schemaTypes",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "schemaTypes"}},
"argument": {"variable": "cx2"}}}},
{
"name": "typeVariables",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.graph.Graph", "fieldName": "typeVariables"}},
"argument": {"variable": "cx2"}}}}]}}}}}}}}}}}},
"annotation": {
"map": [
{
"key": {"variable": "description"},
"value": {"literal": {"string": "Apply a type substitution to a graph's bound types and class constraints"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substInType",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.model.Type"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "typ0",
"domain": {"variable": "hydra.core.model.Type"},
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.logic.ifElse"}, "type": {"variable": "hydra.core.model.Type"}}},
"argument": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.isEmpty"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "subst"}}}}}}},
"argument": {"variable": "typ0"}}},
"argument": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substInTypeNonEmpty"}, "argument": {"variable": "subst"}}},
"argument": {"variable": "typ0"}}}}}}}}},
"annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Apply a type substitution to a type"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substInTypeNonEmpty",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.model.Type"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.model.Type"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "typ0",
"domain": {"variable": "hydra.core.model.Type"},
"body": {
"let": {
"bindings": [
{
"name": "rewrite",
"term": {
"lambda": {
"parameter": "recurse",
"domain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
"body": {
"lambda": {
"parameter": "typ",
"domain": {"variable": "hydra.core.model.Type"},
"body": {
"application": {
"function": {
"cases": {
"typeName": "hydra.core.model.Type",
"default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "typ"}}},
"cases": [
{
"name": "forall",
"handler": {
"lambda": {
"parameter": "lt",
"domain": {"variable": "hydra.core.model.ForallType"},
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
"argument": {"variable": "lt"}}}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "subst"}}}}}}},
"argument": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "typ"}}}}},
"argument": {
"lambda": {
"parameter": "styp",
"domain": {"variable": "hydra.core.model.Type"},
"body": {
"inject": {
"typeName": "hydra.core.model.Type",
"field": {
"name": "forall",
"term": {
"record": {
"typeName": "hydra.core.model.ForallType",
"fields": [
{
"name": "parameter",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
"argument": {"variable": "lt"}}}},
{
"name": "body",
"term": {
"application": {
"function": {
"application": {
"function": {"variable": "hydra.core.substitution.substInType"},
"argument": {
"application": {
"function": {"variable": "removeVar"},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "parameter"}},
"argument": {"variable": "lt"}}}}}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.ForallType", "fieldName": "body"}},
"argument": {"variable": "lt"}}}}}}]}}}}}}}}}}}},
{
"name": "variable",
"handler": {
"lambda": {
"parameter": "v",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Type"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "v"}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "subst"}}}}}}},
"argument": {"variable": "typ"}}},
"argument": {"lambda": {"parameter": "styp", "domain": {"variable": "hydra.core.model.Type"}, "body": {"variable": "styp"}}}}}}}}]}},
"argument": {"variable": "typ"}}}}}}},
"typeScheme": {
"variables": [],
"body": {
"function": {
"domain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}},
"codomain": {"function": {"domain": {"variable": "hydra.core.model.Type"}, "codomain": {"variable": "hydra.core.model.Type"}}}}},
"constraints": []}},
{
"name": "removeVar",
"term": {
"lambda": {
"parameter": "v",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"wrap": {
"typeName": "hydra.core.typing.TypeSubst",
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.delete"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "v"}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "subst"}}}}}}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.Name"}, "codomain": {"variable": "hydra.core.typing.TypeSubst"}}},
"constraints": []}}],
"body": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteType"}, "argument": {"variable": "rewrite"}}},
"argument": {"variable": "typ0"}}}}}}}}},
"annotation": {
"map": [
{
"key": {"variable": "description"},
"value": {"literal": {"string": "Apply a non-empty type substitution to a type (internal helper)"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substInTypeScheme",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.model.TypeScheme"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.model.TypeScheme"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "ts",
"domain": {"variable": "hydra.core.model.TypeScheme"},
"body": {
"let": {
"bindings": [
{
"name": "scopedSubst",
"term": {
"wrap": {
"typeName": "hydra.core.typing.TypeSubst",
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {
"body": {"variable": "hydra.core.lib.lists.foldl"},
"type": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Type"}}}}},
"type": {"variable": "hydra.core.model.Name"}}},
"argument": {
"lambda": {
"parameter": "m",
"domain": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Type"}}},
"body": {
"lambda": {
"parameter": "v",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.delete"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "v"}}},
"argument": {"variable": "m"}}}}}}}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "subst"}}}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
"argument": {"variable": "ts"}}}}}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.typing.TypeSubst"}, "constraints": []}}],
"body": {
"record": {
"typeName": "hydra.core.model.TypeScheme",
"fields": [
{
"name": "variables",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "variables"}},
"argument": {"variable": "ts"}}}},
{
"name": "body",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substInType"}, "argument": {"variable": "scopedSubst"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "body"}},
"argument": {"variable": "ts"}}}}}},
{
"name": "constraints",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substInClassConstraints"}, "argument": {"variable": "scopedSubst"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeScheme", "fieldName": "constraints"}},
"argument": {"variable": "ts"}}}}}}]}}}}}}}},
"annotation": {
"map": [
{
"key": {"variable": "description"},
"value": {
"literal": {
"string": "Apply a type substitution to a type scheme. The scheme's quantifier variables shadow the substitution: any name in typeSchemeVariables is removed from subst before substituting into the body and constraints. Without this, a substitution like {t0 -> Foo} applied to `forall [t0]. t0 -> t0` would incorrectly replace the bound t0."}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substTypesInTerm",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.model.Term"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "term0",
"domain": {"variable": "hydra.core.model.Term"},
"body": {
"let": {
"bindings": [
{
"name": "rewrite",
"term": {
"lambda": {
"parameter": "recurse",
"domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"body": {
"lambda": {
"parameter": "term",
"domain": {"variable": "hydra.core.model.Term"},
"body": {
"let": {
"bindings": [
{
"name": "dflt",
"term": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Term"}, "constraints": []}},
{
"name": "forLambda",
"term": {
"lambda": {
"parameter": "l",
"domain": {"variable": "hydra.core.model.Lambda"},
"body": {
"inject": {
"typeName": "hydra.core.model.Term",
"field": {
"name": "lambda",
"term": {
"record": {
"typeName": "hydra.core.model.Lambda",
"fields": [
{
"name": "parameter",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
"argument": {"variable": "l"}}}},
{
"name": "domain",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.Type"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"application": {"function": {"variable": "hydra.core.substitution.substInType"}, "argument": {"variable": "subst"}}}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "domain"}}, "argument": {"variable": "l"}}}}}},
{
"name": "body",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substTypesInTerm"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}]}}}}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.Lambda"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"constraints": []}},
{
"name": "forLet",
"term": {
"lambda": {
"parameter": "l",
"domain": {"variable": "hydra.core.model.Let"},
"body": {
"let": {
"bindings": [
{
"name": "rewriteBinding",
"term": {
"lambda": {
"parameter": "b",
"domain": {"variable": "hydra.core.model.Binding"},
"body": {
"record": {
"typeName": "hydra.core.model.Binding",
"fields": [
{
"name": "name",
"term": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}},
{
"name": "term",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substTypesInTerm"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}}},
{
"name": "typeScheme",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.map"}, "type": {"variable": "hydra.core.model.TypeScheme"}}},
"type": {"variable": "hydra.core.model.TypeScheme"}}},
"argument": {
"application": {"function": {"variable": "hydra.core.substitution.substInTypeScheme"}, "argument": {"variable": "subst"}}}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
"argument": {"variable": "b"}}}}}}]}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"variable": "hydra.core.model.Binding"}}},
"constraints": []}}],
"body": {
"inject": {
"typeName": "hydra.core.model.Term",
"field": {
"name": "let",
"term": {
"record": {
"typeName": "hydra.core.model.Let",
"fields": [
{
"name": "bindings",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
"type": {"variable": "hydra.core.model.Binding"}}},
"argument": {"variable": "rewriteBinding"}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "l"}}}}}},
{
"name": "body",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substTypesInTerm"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}]}}}}}}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.Let"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"constraints": []}},
{
"name": "forTypeApplication",
"term": {
"lambda": {
"parameter": "tt",
"domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
"body": {
"inject": {
"typeName": "hydra.core.model.Term",
"field": {
"name": "typeApplication",
"term": {
"record": {
"typeName": "hydra.core.model.TypeApplicationTerm",
"fields": [
{
"name": "body",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substTypesInTerm"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "body"}},
"argument": {"variable": "tt"}}}}}},
{
"name": "type",
"term": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.substitution.substInType"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeApplicationTerm", "fieldName": "type"}},
"argument": {"variable": "tt"}}}}}}]}}}}}}},
"typeScheme": {
"variables": [],
"body": {
"function": {"domain": {"variable": "hydra.core.model.TypeApplicationTerm"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"constraints": []}},
{
"name": "forTypeLambda",
"term": {
"lambda": {
"parameter": "ta",
"domain": {"variable": "hydra.core.model.TypeLambda"},
"body": {
"let": {
"bindings": [
{
"name": "param",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "parameter"}},
"argument": {"variable": "ta"}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}},
{
"name": "subst2",
"term": {
"wrap": {
"typeName": "hydra.core.typing.TypeSubst",
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.delete"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Type"}}},
"argument": {"variable": "param"}}},
"argument": {"application": {"function": {"unwrap": "hydra.core.typing.TypeSubst"}, "argument": {"variable": "subst"}}}}}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.typing.TypeSubst"}, "constraints": []}}],
"body": {
"inject": {
"typeName": "hydra.core.model.Term",
"field": {
"name": "typeLambda",
"term": {
"record": {
"typeName": "hydra.core.model.TypeLambda",
"fields": [
{"name": "parameter", "term": {"variable": "param"}},
{
"name": "body",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substTypesInTerm"}, "argument": {"variable": "subst2"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.TypeLambda", "fieldName": "body"}},
"argument": {"variable": "ta"}}}}}}]}}}}}}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.TypeLambda"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"constraints": []}}],
"body": {
"application": {
"function": {
"cases": {
"typeName": "hydra.core.model.Term",
"default": {"variable": "dflt"},
"cases": [
{
"name": "lambda",
"handler": {
"lambda": {
"parameter": "l",
"domain": {"variable": "hydra.core.model.Lambda"},
"body": {"application": {"function": {"variable": "forLambda"}, "argument": {"variable": "l"}}}}}},
{
"name": "let",
"handler": {
"lambda": {
"parameter": "l",
"domain": {"variable": "hydra.core.model.Let"},
"body": {"application": {"function": {"variable": "forLet"}, "argument": {"variable": "l"}}}}}},
{
"name": "typeApplication",
"handler": {
"lambda": {
"parameter": "ta",
"domain": {"variable": "hydra.core.model.TypeApplicationTerm"},
"body": {"application": {"function": {"variable": "forTypeApplication"}, "argument": {"variable": "ta"}}}}}},
{
"name": "typeLambda",
"handler": {
"lambda": {
"parameter": "tl",
"domain": {"variable": "hydra.core.model.TypeLambda"},
"body": {"application": {"function": {"variable": "forTypeLambda"}, "argument": {"variable": "tl"}}}}}}]}},
"argument": {"variable": "term"}}}}}}}}},
"typeScheme": {
"variables": [],
"body": {
"function": {
"domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
"constraints": []}}],
"body": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteTerm"}, "argument": {"variable": "rewrite"}}},
"argument": {"variable": "term0"}}}}}}}}},
"annotation": {
"map": [
{
"key": {"variable": "description"},
"value": {"literal": {"string": "Apply a type substitution to the type annotations within a term"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substituteInBinding",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TermSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.model.Binding"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.model.Binding"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TermSubst"},
"body": {
"lambda": {
"parameter": "b",
"domain": {"variable": "hydra.core.model.Binding"},
"body": {
"record": {
"typeName": "hydra.core.model.Binding",
"fields": [
{
"name": "name",
"term": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}},
{
"name": "term",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substituteInTerm"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}}},
{
"name": "typeScheme",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
"argument": {"variable": "b"}}}}]}}}}}},
"annotation": {
"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Apply a term substitution to a binding"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substituteInConstraint",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.typing.TypeConstraint"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.typing.TypeConstraint"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "c",
"domain": {"variable": "hydra.core.typing.TypeConstraint"},
"body": {
"record": {
"typeName": "hydra.core.typing.TypeConstraint",
"fields": [
{
"name": "left",
"term": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.substitution.substInType"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.typing.TypeConstraint", "fieldName": "left"}},
"argument": {"variable": "c"}}}}}},
{
"name": "right",
"term": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.substitution.substInType"}, "argument": {"variable": "subst"}}},
"argument": {
"application": {
"function": {"project": {"typeName": "hydra.core.typing.TypeConstraint", "fieldName": "right"}},
"argument": {"variable": "c"}}}}}},
{
"name": "comment",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.typing.TypeConstraint", "fieldName": "comment"}},
"argument": {"variable": "c"}}}}]}}}}}},
"annotation": {
"map": [
{"key": {"variable": "description"}, "value": {"literal": {"string": "Apply a type substitution to a type constraint"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substituteInConstraints",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TypeSubst"}, "isLazy": false},
{"name": "arg1", "type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}, "isLazy": false}],
"result": {"type": {"list": {"variable": "hydra.core.typing.TypeConstraint"}}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TypeSubst"},
"body": {
"lambda": {
"parameter": "cs",
"domain": {"list": {"variable": "hydra.core.typing.TypeConstraint"}},
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.typing.TypeConstraint"}}},
"type": {"variable": "hydra.core.typing.TypeConstraint"}}},
"argument": {
"application": {"function": {"variable": "hydra.core.substitution.substituteInConstraint"}, "argument": {"variable": "subst"}}}}},
"argument": {"variable": "cs"}}}}}}},
"annotation": {
"map": [
{
"key": {"variable": "description"},
"value": {"literal": {"string": "Apply a type substitution to a list of type constraints"}}}]}}}}},
{
"term": {
"name": "hydra.core.substitution.substituteInTerm",
"signature": {
"typeParameters": [],
"parameters": [
{"name": "arg0", "type": {"variable": "hydra.core.typing.TermSubst"}, "isLazy": false},
{"name": "arg1", "type": {"variable": "hydra.core.model.Term"}, "isLazy": false}],
"result": {"type": {"variable": "hydra.core.model.Term"}}},
"body": {
"annotated": {
"body": {
"lambda": {
"parameter": "subst",
"domain": {"variable": "hydra.core.typing.TermSubst"},
"body": {
"lambda": {
"parameter": "term0",
"domain": {"variable": "hydra.core.model.Term"},
"body": {
"let": {
"bindings": [
{
"name": "s",
"term": {"application": {"function": {"unwrap": "hydra.core.typing.TermSubst"}, "argument": {"variable": "subst"}}},
"typeScheme": {
"variables": [],
"body": {"map": {"keys": {"variable": "hydra.core.model.Name"}, "values": {"variable": "hydra.core.model.Term"}}},
"constraints": []}},
{
"name": "rewrite",
"term": {
"lambda": {
"parameter": "recurse",
"domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"body": {
"lambda": {
"parameter": "term",
"domain": {"variable": "hydra.core.model.Term"},
"body": {
"let": {
"bindings": [
{
"name": "withLambda",
"term": {
"lambda": {
"parameter": "l",
"domain": {"variable": "hydra.core.model.Lambda"},
"body": {
"let": {
"bindings": [
{
"name": "v",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "parameter"}},
"argument": {"variable": "l"}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.model.Name"}, "constraints": []}},
{
"name": "subst2",
"term": {
"wrap": {
"typeName": "hydra.core.typing.TermSubst",
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.delete"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Term"}}},
"argument": {"variable": "v"}}},
"argument": {"variable": "s"}}}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.typing.TermSubst"}, "constraints": []}}],
"body": {
"inject": {
"typeName": "hydra.core.model.Term",
"field": {
"name": "lambda",
"term": {
"record": {
"typeName": "hydra.core.model.Lambda",
"fields": [
{"name": "parameter", "term": {"variable": "v"}},
{
"name": "domain",
"term": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "domain"}}, "argument": {"variable": "l"}}}},
{
"name": "body",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substituteInTerm"}, "argument": {"variable": "subst2"}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Lambda", "fieldName": "body"}}, "argument": {"variable": "l"}}}}}}]}}}}}}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.Lambda"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"constraints": []}},
{
"name": "withLet",
"term": {
"lambda": {
"parameter": "lt",
"domain": {"variable": "hydra.core.model.Let"},
"body": {
"let": {
"bindings": [
{
"name": "bindings",
"term": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "bindings"}}, "argument": {"variable": "lt"}}},
"typeScheme": {"variables": [], "body": {"list": {"variable": "hydra.core.model.Binding"}}, "constraints": []}},
{
"name": "names",
"term": {
"application": {
"function": {
"typeApplication": {"body": {"variable": "hydra.core.lib.sets.fromList"}, "type": {"variable": "hydra.core.model.Name"}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
"type": {"variable": "hydra.core.model.Name"}}},
"argument": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}}},
"argument": {"variable": "bindings"}}}}},
"typeScheme": {"variables": [], "body": {"set": {"variable": "hydra.core.model.Name"}}, "constraints": []}},
{
"name": "subst2",
"term": {
"wrap": {
"typeName": "hydra.core.typing.TermSubst",
"body": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.maps.filterWithKey"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Term"}}},
"argument": {
"lambda": {
"parameter": "k",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"lambda": {
"parameter": "v",
"domain": {"variable": "hydra.core.model.Term"},
"body": {
"application": {
"function": {"variable": "hydra.core.lib.logic.not"},
"argument": {
"application": {
"function": {
"application": {
"function": {"typeApplication": {"body": {"variable": "hydra.core.lib.sets.member"}, "type": {"variable": "hydra.core.model.Name"}}},
"argument": {"variable": "k"}}},
"argument": {"variable": "names"}}}}}}}}}}},
"argument": {"variable": "s"}}}}},
"typeScheme": {"variables": [], "body": {"variable": "hydra.core.typing.TermSubst"}, "constraints": []}},
{
"name": "rewriteBinding",
"term": {
"lambda": {
"parameter": "b",
"domain": {"variable": "hydra.core.model.Binding"},
"body": {
"record": {
"typeName": "hydra.core.model.Binding",
"fields": [
{
"name": "name",
"term": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "name"}}, "argument": {"variable": "b"}}}},
{
"name": "term",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substituteInTerm"}, "argument": {"variable": "subst2"}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "term"}}, "argument": {"variable": "b"}}}}}},
{
"name": "typeScheme",
"term": {
"application": {
"function": {"project": {"typeName": "hydra.core.model.Binding", "fieldName": "typeScheme"}},
"argument": {"variable": "b"}}}}]}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.Binding"}, "codomain": {"variable": "hydra.core.model.Binding"}}},
"constraints": []}}],
"body": {
"inject": {
"typeName": "hydra.core.model.Term",
"field": {
"name": "let",
"term": {
"record": {
"typeName": "hydra.core.model.Let",
"fields": [
{
"name": "bindings",
"term": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.lists.map"}, "type": {"variable": "hydra.core.model.Binding"}}},
"type": {"variable": "hydra.core.model.Binding"}}},
"argument": {"variable": "rewriteBinding"}}},
"argument": {"variable": "bindings"}}}},
{
"name": "body",
"term": {
"application": {
"function": {
"application": {"function": {"variable": "hydra.core.substitution.substituteInTerm"}, "argument": {"variable": "subst2"}}},
"argument": {
"application": {"function": {"project": {"typeName": "hydra.core.model.Let", "fieldName": "body"}}, "argument": {"variable": "lt"}}}}}}]}}}}}}}}},
"typeScheme": {
"variables": [],
"body": {"function": {"domain": {"variable": "hydra.core.model.Let"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"constraints": []}}],
"body": {
"application": {
"function": {
"cases": {
"typeName": "hydra.core.model.Term",
"default": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}},
"cases": [
{
"name": "lambda",
"handler": {
"lambda": {
"parameter": "l",
"domain": {"variable": "hydra.core.model.Lambda"},
"body": {"application": {"function": {"variable": "withLambda"}, "argument": {"variable": "l"}}}}}},
{
"name": "let",
"handler": {
"lambda": {
"parameter": "l",
"domain": {"variable": "hydra.core.model.Let"},
"body": {"application": {"function": {"variable": "withLet"}, "argument": {"variable": "l"}}}}}},
{
"name": "variable",
"handler": {
"lambda": {
"parameter": "name",
"domain": {"variable": "hydra.core.model.Name"},
"body": {
"application": {
"function": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {
"typeApplication": {"body": {"variable": "hydra.core.lib.optionals.match"}, "type": {"variable": "hydra.core.model.Term"}}},
"type": {"variable": "hydra.core.model.Term"}}},
"argument": {
"application": {
"function": {
"application": {
"function": {
"typeApplication": {
"body": {"typeApplication": {"body": {"variable": "hydra.core.lib.maps.lookup"}, "type": {"variable": "hydra.core.model.Name"}}},
"type": {"variable": "hydra.core.model.Term"}}},
"argument": {"variable": "name"}}},
"argument": {"variable": "s"}}}}},
"argument": {"application": {"function": {"variable": "recurse"}, "argument": {"variable": "term"}}}}},
"argument": {"lambda": {"parameter": "sterm", "domain": {"variable": "hydra.core.model.Term"}, "body": {"variable": "sterm"}}}}}}}}]}},
"argument": {"variable": "term"}}}}}}}}},
"typeScheme": {
"variables": [],
"body": {
"function": {
"domain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}},
"codomain": {"function": {"domain": {"variable": "hydra.core.model.Term"}, "codomain": {"variable": "hydra.core.model.Term"}}}}},
"constraints": []}}],
"body": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.rewriting.rewriteTerm"}, "argument": {"variable": "rewrite"}}},
"argument": {"variable": "term0"}}}}}}}}},
"annotation": {"map": [{"key": {"variable": "description"}, "value": {"literal": {"string": "Apply a term substitution to a term"}}}]}}}}}]}