hinmil 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2306 -2
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +338 -0
- package/dist/cli.js.map +1 -0
- package/dist/commentParser.d.ts +384 -0
- package/dist/commentParser.d.ts.map +1 -0
- package/dist/commentParser.js +2487 -0
- package/dist/commentParser.js.map +1 -0
- package/dist/config.d.ts +203 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +375 -0
- package/dist/config.js.map +1 -0
- package/dist/debugLog.d.ts +13 -0
- package/dist/debugLog.d.ts.map +1 -0
- package/dist/debugLog.js +44 -0
- package/dist/debugLog.js.map +1 -0
- package/dist/estree.d.ts +100 -0
- package/dist/estree.d.ts.map +1 -0
- package/dist/estree.js +34 -0
- package/dist/estree.js.map +1 -0
- package/dist/hm/env.d.ts +134 -0
- package/dist/hm/env.d.ts.map +1 -0
- package/dist/hm/env.js +939 -0
- package/dist/hm/env.js.map +1 -0
- package/dist/hm/index.d.ts +7 -0
- package/dist/hm/index.d.ts.map +1 -0
- package/dist/hm/index.js +26 -0
- package/dist/hm/index.js.map +1 -0
- package/dist/hm/substitution.d.ts +57 -0
- package/dist/hm/substitution.d.ts.map +1 -0
- package/dist/hm/substitution.js +546 -0
- package/dist/hm/substitution.js.map +1 -0
- package/dist/hm/typeParser.d.ts +39 -0
- package/dist/hm/typeParser.d.ts.map +1 -0
- package/dist/hm/typeParser.js +1285 -0
- package/dist/hm/typeParser.js.map +1 -0
- package/dist/hm/typeUtils.d.ts +248 -0
- package/dist/hm/typeUtils.d.ts.map +1 -0
- package/dist/hm/typeUtils.js +905 -0
- package/dist/hm/typeUtils.js.map +1 -0
- package/dist/hm/types.d.ts +738 -0
- package/dist/hm/types.d.ts.map +1 -0
- package/dist/hm/types.js +1853 -0
- package/dist/hm/types.js.map +1 -0
- package/dist/hm/unify.d.ts +59 -0
- package/dist/hm/unify.d.ts.map +1 -0
- package/dist/hm/unify.js +1700 -0
- package/dist/hm/unify.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +196 -0
- package/dist/index.js.map +1 -0
- package/dist/infer/annotation-rigid.d.ts +76 -0
- package/dist/infer/annotation-rigid.d.ts.map +1 -0
- package/dist/infer/annotation-rigid.js +542 -0
- package/dist/infer/annotation-rigid.js.map +1 -0
- package/dist/infer/annotation-validation.d.ts +109 -0
- package/dist/infer/annotation-validation.d.ts.map +1 -0
- package/dist/infer/annotation-validation.js +1078 -0
- package/dist/infer/annotation-validation.js.map +1 -0
- package/dist/infer/annotations.d.ts +277 -0
- package/dist/infer/annotations.d.ts.map +1 -0
- package/dist/infer/annotations.js +1343 -0
- package/dist/infer/annotations.js.map +1 -0
- package/dist/infer/call-overloads.d.ts +24 -0
- package/dist/infer/call-overloads.d.ts.map +1 -0
- package/dist/infer/call-overloads.js +900 -0
- package/dist/infer/call-overloads.js.map +1 -0
- package/dist/infer/call-rows.d.ts +154 -0
- package/dist/infer/call-rows.d.ts.map +1 -0
- package/dist/infer/call-rows.js +2162 -0
- package/dist/infer/call-rows.js.map +1 -0
- package/dist/infer/calls.d.ts +20 -0
- package/dist/infer/calls.d.ts.map +1 -0
- package/dist/infer/calls.js +1468 -0
- package/dist/infer/calls.js.map +1 -0
- package/dist/infer/constraints.d.ts +99 -0
- package/dist/infer/constraints.d.ts.map +1 -0
- package/dist/infer/constraints.js +1208 -0
- package/dist/infer/constraints.js.map +1 -0
- package/dist/infer/expr-assignment.d.ts +20 -0
- package/dist/infer/expr-assignment.d.ts.map +1 -0
- package/dist/infer/expr-assignment.js +620 -0
- package/dist/infer/expr-assignment.js.map +1 -0
- package/dist/infer/expr-constraint-lookup.d.ts +44 -0
- package/dist/infer/expr-constraint-lookup.d.ts.map +1 -0
- package/dist/infer/expr-constraint-lookup.js +207 -0
- package/dist/infer/expr-constraint-lookup.js.map +1 -0
- package/dist/infer/expr-functions.d.ts +20 -0
- package/dist/infer/expr-functions.d.ts.map +1 -0
- package/dist/infer/expr-functions.js +1359 -0
- package/dist/infer/expr-functions.js.map +1 -0
- package/dist/infer/expr-jsx.d.ts +19 -0
- package/dist/infer/expr-jsx.d.ts.map +1 -0
- package/dist/infer/expr-jsx.js +310 -0
- package/dist/infer/expr-jsx.js.map +1 -0
- package/dist/infer/expr-member.d.ts +40 -0
- package/dist/infer/expr-member.d.ts.map +1 -0
- package/dist/infer/expr-member.js +1154 -0
- package/dist/infer/expr-member.js.map +1 -0
- package/dist/infer/expr-prototype.d.ts +11 -0
- package/dist/infer/expr-prototype.d.ts.map +1 -0
- package/dist/infer/expr-prototype.js +202 -0
- package/dist/infer/expr-prototype.js.map +1 -0
- package/dist/infer/expressions.d.ts +40 -0
- package/dist/infer/expressions.d.ts.map +1 -0
- package/dist/infer/expressions.js +1497 -0
- package/dist/infer/expressions.js.map +1 -0
- package/dist/infer/functionPatterns.d.ts +229 -0
- package/dist/infer/functionPatterns.d.ts.map +1 -0
- package/dist/infer/functionPatterns.js +1035 -0
- package/dist/infer/functionPatterns.js.map +1 -0
- package/dist/infer/helpers.d.ts +73 -0
- package/dist/infer/helpers.d.ts.map +1 -0
- package/dist/infer/helpers.js +187 -0
- package/dist/infer/helpers.js.map +1 -0
- package/dist/infer/index.d.ts +551 -0
- package/dist/infer/index.d.ts.map +1 -0
- package/dist/infer/index.js +1127 -0
- package/dist/infer/index.js.map +1 -0
- package/dist/infer/jsx-dom.d.ts +26 -0
- package/dist/infer/jsx-dom.d.ts.map +1 -0
- package/dist/infer/jsx-dom.js +303 -0
- package/dist/infer/jsx-dom.js.map +1 -0
- package/dist/infer/moduleReps.d.ts +7 -0
- package/dist/infer/moduleReps.d.ts.map +1 -0
- package/dist/infer/moduleReps.js +48 -0
- package/dist/infer/moduleReps.js.map +1 -0
- package/dist/infer/modules.d.ts +10 -0
- package/dist/infer/modules.d.ts.map +1 -0
- package/dist/infer/modules.js +775 -0
- package/dist/infer/modules.js.map +1 -0
- package/dist/infer/narrowing.d.ts +199 -0
- package/dist/infer/narrowing.d.ts.map +1 -0
- package/dist/infer/narrowing.js +1428 -0
- package/dist/infer/narrowing.js.map +1 -0
- package/dist/infer/results.d.ts +24 -0
- package/dist/infer/results.d.ts.map +1 -0
- package/dist/infer/results.js +611 -0
- package/dist/infer/results.js.map +1 -0
- package/dist/infer/setupPass.d.ts +11 -0
- package/dist/infer/setupPass.d.ts.map +1 -0
- package/dist/infer/setupPass.js +524 -0
- package/dist/infer/setupPass.js.map +1 -0
- package/dist/infer/statements.d.ts +26 -0
- package/dist/infer/statements.d.ts.map +1 -0
- package/dist/infer/statements.js +750 -0
- package/dist/infer/statements.js.map +1 -0
- package/dist/infer/stmt-bindings.d.ts +22 -0
- package/dist/infer/stmt-bindings.d.ts.map +1 -0
- package/dist/infer/stmt-bindings.js +1482 -0
- package/dist/infer/stmt-bindings.js.map +1 -0
- package/dist/infer/stmt-destructure.d.ts +29 -0
- package/dist/infer/stmt-destructure.d.ts.map +1 -0
- package/dist/infer/stmt-destructure.js +490 -0
- package/dist/infer/stmt-destructure.js.map +1 -0
- package/dist/infer/types.d.ts +220 -0
- package/dist/infer/types.d.ts.map +1 -0
- package/dist/infer/types.js +46 -0
- package/dist/infer/types.js.map +1 -0
- package/dist/infer/unifyDiag.d.ts +46 -0
- package/dist/infer/unifyDiag.d.ts.map +1 -0
- package/dist/infer/unifyDiag.js +642 -0
- package/dist/infer/unifyDiag.js.map +1 -0
- package/dist/parsing-babel.d.ts +3 -0
- package/dist/parsing-babel.d.ts.map +1 -0
- package/dist/parsing-babel.js +353 -0
- package/dist/parsing-babel.js.map +1 -0
- package/dist/parsing.d.ts +69 -0
- package/dist/parsing.d.ts.map +1 -0
- package/dist/parsing.js +288 -0
- package/dist/parsing.js.map +1 -0
- package/dist/registries/constraintRegistry.d.ts +233 -0
- package/dist/registries/constraintRegistry.d.ts.map +1 -0
- package/dist/registries/constraintRegistry.js +803 -0
- package/dist/registries/constraintRegistry.js.map +1 -0
- package/dist/registries/dataTypeRegistry.d.ts +63 -0
- package/dist/registries/dataTypeRegistry.d.ts.map +1 -0
- package/dist/registries/dataTypeRegistry.js +180 -0
- package/dist/registries/dataTypeRegistry.js.map +1 -0
- package/dist/registries/domGlobals.d.ts +33 -0
- package/dist/registries/domGlobals.d.ts.map +1 -0
- package/dist/registries/domGlobals.js +309 -0
- package/dist/registries/domGlobals.js.map +1 -0
- package/dist/registries/methodRegistry.d.ts +277 -0
- package/dist/registries/methodRegistry.d.ts.map +1 -0
- package/dist/registries/methodRegistry.js +2074 -0
- package/dist/registries/methodRegistry.js.map +1 -0
- package/dist/registries/session.d.ts +38 -0
- package/dist/registries/session.d.ts.map +1 -0
- package/dist/registries/session.js +75 -0
- package/dist/registries/session.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1896 -0
- package/dist/server.js.map +1 -0
- package/dist/services/codeActions.d.ts +22 -0
- package/dist/services/codeActions.d.ts.map +1 -0
- package/dist/services/codeActions.js +465 -0
- package/dist/services/codeActions.js.map +1 -0
- package/dist/services/completion.d.ts +259 -0
- package/dist/services/completion.d.ts.map +1 -0
- package/dist/services/completion.js +2794 -0
- package/dist/services/completion.js.map +1 -0
- package/dist/services/definitions.d.ts +37 -0
- package/dist/services/definitions.d.ts.map +1 -0
- package/dist/services/definitions.js +605 -0
- package/dist/services/definitions.js.map +1 -0
- package/dist/services/diagnosticCodes.d.ts +70 -0
- package/dist/services/diagnosticCodes.d.ts.map +1 -0
- package/dist/services/diagnosticCodes.js +239 -0
- package/dist/services/diagnosticCodes.js.map +1 -0
- package/dist/services/diagnostics.d.ts +86 -0
- package/dist/services/diagnostics.d.ts.map +1 -0
- package/dist/services/diagnostics.js +665 -0
- package/dist/services/diagnostics.js.map +1 -0
- package/dist/services/documentCache.d.ts +88 -0
- package/dist/services/documentCache.d.ts.map +1 -0
- package/dist/services/documentCache.js +108 -0
- package/dist/services/documentCache.js.map +1 -0
- package/dist/services/documentSymbols.d.ts +20 -0
- package/dist/services/documentSymbols.d.ts.map +1 -0
- package/dist/services/documentSymbols.js +381 -0
- package/dist/services/documentSymbols.js.map +1 -0
- package/dist/services/fileSelection.d.ts +24 -0
- package/dist/services/fileSelection.d.ts.map +1 -0
- package/dist/services/fileSelection.js +154 -0
- package/dist/services/fileSelection.js.map +1 -0
- package/dist/services/fileSelectionRefresh.d.ts +26 -0
- package/dist/services/fileSelectionRefresh.d.ts.map +1 -0
- package/dist/services/fileSelectionRefresh.js +77 -0
- package/dist/services/fileSelectionRefresh.js.map +1 -0
- package/dist/services/files.d.ts +342 -0
- package/dist/services/files.d.ts.map +1 -0
- package/dist/services/files.js +1712 -0
- package/dist/services/files.js.map +1 -0
- package/dist/services/fsProbe.d.ts +14 -0
- package/dist/services/fsProbe.d.ts.map +1 -0
- package/dist/services/fsProbe.js +112 -0
- package/dist/services/fsProbe.js.map +1 -0
- package/dist/services/globalsLoader.d.ts +20 -0
- package/dist/services/globalsLoader.d.ts.map +1 -0
- package/dist/services/globalsLoader.js +122 -0
- package/dist/services/globalsLoader.js.map +1 -0
- package/dist/services/hmFileServices.d.ts +113 -0
- package/dist/services/hmFileServices.d.ts.map +1 -0
- package/dist/services/hmFileServices.js +686 -0
- package/dist/services/hmFileServices.js.map +1 -0
- package/dist/services/hover.d.ts +280 -0
- package/dist/services/hover.d.ts.map +1 -0
- package/dist/services/hover.js +1687 -0
- package/dist/services/hover.js.map +1 -0
- package/dist/services/importContext.d.ts +396 -0
- package/dist/services/importContext.d.ts.map +1 -0
- package/dist/services/importContext.js +1999 -0
- package/dist/services/importContext.js.map +1 -0
- package/dist/services/projectChecker.d.ts +50 -0
- package/dist/services/projectChecker.d.ts.map +1 -0
- package/dist/services/projectChecker.js +228 -0
- package/dist/services/projectChecker.js.map +1 -0
- package/dist/services/references.d.ts +41 -0
- package/dist/services/references.d.ts.map +1 -0
- package/dist/services/references.js +757 -0
- package/dist/services/references.js.map +1 -0
- package/dist/services/rename.d.ts +22 -0
- package/dist/services/rename.d.ts.map +1 -0
- package/dist/services/rename.js +101 -0
- package/dist/services/rename.js.map +1 -0
- package/dist/services/shortCircuit.d.ts +27 -0
- package/dist/services/shortCircuit.d.ts.map +1 -0
- package/dist/services/shortCircuit.js +28 -0
- package/dist/services/shortCircuit.js.map +1 -0
- package/dist/services/sidecarPerf.d.ts +19 -0
- package/dist/services/sidecarPerf.d.ts.map +1 -0
- package/dist/services/sidecarPerf.js +59 -0
- package/dist/services/sidecarPerf.js.map +1 -0
- package/dist/services/signatureHelp.d.ts +27 -0
- package/dist/services/signatureHelp.d.ts.map +1 -0
- package/dist/services/signatureHelp.js +984 -0
- package/dist/services/signatureHelp.js.map +1 -0
- package/dist/walking.d.ts +25 -0
- package/dist/walking.d.ts.map +1 -0
- package/dist/walking.js +107 -0
- package/dist/walking.js.map +1 -0
- package/hm-types-builtin/assert.hm +20 -0
- package/hm-types-builtin/buffer.hm +8 -0
- package/hm-types-builtin/child_process.hm +16 -0
- package/hm-types-builtin/crypto.hm +17 -0
- package/hm-types-builtin/fs.hm +15 -0
- package/hm-types-builtin/http.hm +14 -0
- package/hm-types-builtin/os.hm +19 -0
- package/hm-types-builtin/path.hm +18 -0
- package/hm-types-builtin/react-dom.hm +27 -0
- package/hm-types-builtin/react.hm +113 -0
- package/hm-types-builtin/url.hm +7 -0
- package/hm-types-builtin/zlib.hm +12 -0
- package/package.json +53 -4
- package/schemas/hinmil.config.schema.json +261 -0
- package/schemas/package-hinmil.schema.json +59 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// Substitution — mapping from type-variable ids to types
|
|
4
|
+
//
|
|
5
|
+
// WHAT THIS FILE DOES (in plain language)
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// While the puzzle solver (unify.ts) works, it learns answers like
|
|
8
|
+
// "placeholder #12 must be Number". A Substitution is the growing answer
|
|
9
|
+
// sheet holding all of those: a table from placeholder id to type.
|
|
10
|
+
//
|
|
11
|
+
// The two important operations:
|
|
12
|
+
// • apply(t) — rewrite type `t`, replacing every placeholder that has
|
|
13
|
+
// an answer with that answer (chasing chains: if #12 = #14
|
|
14
|
+
// and #14 = Number, then #12 becomes Number).
|
|
15
|
+
// • compose(other) — combine two answer sheets into one, so the answers of
|
|
16
|
+
// a later unification step are merged with earlier ones.
|
|
17
|
+
//
|
|
18
|
+
// apply() also performs a handful of deferred rewrites that could not be
|
|
19
|
+
// finished during unification itself (row splicing into records, kv-name
|
|
20
|
+
// resolution, merge-row deep merging) — see the inline comments below.
|
|
21
|
+
// ============================================================================
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.Substitution = void 0;
|
|
24
|
+
const types_1 = require("./types");
|
|
25
|
+
const typeUtils_1 = require("./typeUtils");
|
|
26
|
+
const dataTypeRegistry_1 = require("../registries/dataTypeRegistry");
|
|
27
|
+
class Substitution {
|
|
28
|
+
constructor(entries) {
|
|
29
|
+
/** Records currently being substituted on this call stack (cycle guard). */
|
|
30
|
+
this.recordsInProgress = new Set();
|
|
31
|
+
this.map = new Map(entries);
|
|
32
|
+
}
|
|
33
|
+
/** Create a substitution with a single binding. */
|
|
34
|
+
static singleton(id, type) {
|
|
35
|
+
const s = new Substitution();
|
|
36
|
+
s.map.set(id, type);
|
|
37
|
+
return s;
|
|
38
|
+
}
|
|
39
|
+
/** Look up a type variable id. */
|
|
40
|
+
lookup(id) {
|
|
41
|
+
return this.map.get(id);
|
|
42
|
+
}
|
|
43
|
+
/** Extend the substitution with a new binding. */
|
|
44
|
+
set(id, type) {
|
|
45
|
+
this.map.set(id, type);
|
|
46
|
+
}
|
|
47
|
+
/** Number of bindings. */
|
|
48
|
+
get size() {
|
|
49
|
+
return this.map.size;
|
|
50
|
+
}
|
|
51
|
+
/** Apply this substitution to a type, recursively resolving variables. */
|
|
52
|
+
apply(t, _visited) {
|
|
53
|
+
// Fast path: an empty substitution can never change anything.
|
|
54
|
+
if (this.map.size === 0)
|
|
55
|
+
return t;
|
|
56
|
+
switch (t.tag) {
|
|
57
|
+
case 'TVar': {
|
|
58
|
+
const resolved = this.map.get(t.id);
|
|
59
|
+
if (resolved) {
|
|
60
|
+
// Guard against self-referencing substitutions
|
|
61
|
+
if (resolved.tag === 'TVar' && resolved.id === t.id) {
|
|
62
|
+
return t;
|
|
63
|
+
}
|
|
64
|
+
// Guard against indirect TVar cycles
|
|
65
|
+
const visited = _visited ?? new Set();
|
|
66
|
+
if (visited.has(t.id))
|
|
67
|
+
return t;
|
|
68
|
+
visited.add(t.id);
|
|
69
|
+
// Chase the substitution chain
|
|
70
|
+
return this.apply(resolved, visited);
|
|
71
|
+
}
|
|
72
|
+
return t;
|
|
73
|
+
}
|
|
74
|
+
case 'TCon': {
|
|
75
|
+
// Short-circuit: ground types (zero args, no kv) have nothing to substitute
|
|
76
|
+
const kv = (0, types_1.parseKvName)(t.name);
|
|
77
|
+
if (t.args.length === 0 && !kv)
|
|
78
|
+
return t;
|
|
79
|
+
let name = t.name;
|
|
80
|
+
// Resolve kind-variable TCon names through substitution
|
|
81
|
+
let extraArgs = [];
|
|
82
|
+
if (kv) {
|
|
83
|
+
const resolved = this.map.get(kv.varId);
|
|
84
|
+
if (resolved) {
|
|
85
|
+
// Guard against cycles through kind-variable resolution
|
|
86
|
+
const visited = _visited ?? new Set();
|
|
87
|
+
if (visited.has(kv.varId))
|
|
88
|
+
return t;
|
|
89
|
+
visited.add(kv.varId);
|
|
90
|
+
// Chase the chain
|
|
91
|
+
const final = this.apply(resolved, visited);
|
|
92
|
+
if (final.tag === 'TCon') {
|
|
93
|
+
// Kind/arity guard: a kv var that resolves to a registered
|
|
94
|
+
// data type must produce a saturated TCon (`extraArgs +
|
|
95
|
+
// t.args` covers all declared type parameters). If we'd
|
|
96
|
+
// produce an under-saturated TCon (e.g. bare `m` resolved
|
|
97
|
+
// to `Either e` → unary `Either`), keep the kv form so
|
|
98
|
+
// downstream rendering shows `m` rather than a malformed
|
|
99
|
+
// type. This protects against partial-application
|
|
100
|
+
// leakage when intermediate unification left a bare kv.
|
|
101
|
+
const decl = (0, dataTypeRegistry_1.getDataType)(final.name);
|
|
102
|
+
if (decl) {
|
|
103
|
+
const declaredArity = decl.decl.typeVars.length;
|
|
104
|
+
if (final.args.length + t.args.length < declaredArity) {
|
|
105
|
+
return t;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
name = final.name;
|
|
109
|
+
// Include args from partially applied constructors
|
|
110
|
+
// (e.g. kv bound to `RTask r e` → extraArgs = [r, e]).
|
|
111
|
+
// EXCEPT when the binding is itself a kv *application*
|
|
112
|
+
// (`$kv:f(a)` — e.g. a pinned `TypeRep (f a)` param that bound
|
|
113
|
+
// a callee's bare rep var): its args are one particular
|
|
114
|
+
// APPLICATION of the constructor, not part of the
|
|
115
|
+
// constructor's identity. Absorbing them would double the
|
|
116
|
+
// arity at every other usage site (`f c` → ill-kinded `f a c`).
|
|
117
|
+
extraArgs = (0, types_1.parseKvName)(final.name) && t.args.length > 0 ? [] : final.args;
|
|
118
|
+
// Over-saturation guard (mirror of the under-saturation check
|
|
119
|
+
// above): a kv var bound to one SATURATED application
|
|
120
|
+
// (`m := Either e a`, e.g. from a sumtype rep typed
|
|
121
|
+
// `TypeRep (Either e a)`) that is RE-applied at a usage site
|
|
122
|
+
// (`m c`) would otherwise produce the ill-kinded
|
|
123
|
+
// `Either e a c`. The binding's trailing type-VARIABLE args
|
|
124
|
+
// are one particular element application — not part of the
|
|
125
|
+
// constructor's identity — so drop them until the declared
|
|
126
|
+
// arity fits. Concrete trailing args are kept (and surface
|
|
127
|
+
// a genuine arity error). Bare usages (`m`, no args) keep
|
|
128
|
+
// the full saturated binding.
|
|
129
|
+
if (decl && t.args.length > 0) {
|
|
130
|
+
const declaredArity = decl.decl.typeVars.length;
|
|
131
|
+
while (extraArgs.length > 0
|
|
132
|
+
&& extraArgs.length + t.args.length > declaredArity
|
|
133
|
+
&& extraArgs[extraArgs.length - 1].tag === 'TVar') {
|
|
134
|
+
extraArgs = extraArgs.slice(0, -1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (final.tag === 'TVar') {
|
|
139
|
+
// When the kv var maps to another TVar, rename the kv to
|
|
140
|
+
// track the new id so constraint lookups use the correct entry.
|
|
141
|
+
name = (0, types_1.kvName)(kv.varName, final.id);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
let newArgs = [...extraArgs, ...t.args.map((a) => this.apply(a, _visited))];
|
|
146
|
+
// A kind variable bound to the bare `Function` constructor and applied
|
|
147
|
+
// to two arguments is a function used as a binary constructor
|
|
148
|
+
// (Profunctor, see unify): `p b c` is `Function [b] c`.
|
|
149
|
+
if (kv && name === types_1.T_FUNCTION && extraArgs.length === 0 && t.args.length === 2) {
|
|
150
|
+
newArgs = [(0, types_1.tCon)(types_1.T_ARRAY, [newArgs[0]]), newArgs[1]];
|
|
151
|
+
}
|
|
152
|
+
if (name === types_1.T_UNION) {
|
|
153
|
+
// Nothing substituted: the union is returned as is. Rebuilding it
|
|
154
|
+
// re-sorts the members by their rendered text, the single largest
|
|
155
|
+
// cost of `apply` on real projects.
|
|
156
|
+
if (extraArgs.length === 0 && newArgs.length === t.args.length
|
|
157
|
+
&& newArgs.every((a, i) => a === t.args[i])) {
|
|
158
|
+
return t;
|
|
159
|
+
}
|
|
160
|
+
return (0, types_1.tUnion)(newArgs, { overloadSet: t.overloadSet });
|
|
161
|
+
}
|
|
162
|
+
// Structural sharing: return original if nothing changed
|
|
163
|
+
if (name === t.name && extraArgs.length === 0 &&
|
|
164
|
+
newArgs.length === t.args.length &&
|
|
165
|
+
newArgs.every((a, i) => a === t.args[i])) {
|
|
166
|
+
return t;
|
|
167
|
+
}
|
|
168
|
+
const out = { tag: 'TCon', name, args: newArgs };
|
|
169
|
+
// Preserve any display-only `paramHint` attached at call-site
|
|
170
|
+
// post-processing (see `bindParamSlot` in `src/infer/calls.ts`).
|
|
171
|
+
// Recursively apply the substitution so e.g. record-field types
|
|
172
|
+
// inside the hint are kept up to date.
|
|
173
|
+
if (t.paramHint)
|
|
174
|
+
out.paramHint = this.apply(t.paramHint, _visited);
|
|
175
|
+
// Preserve the strict-empty-array marker (`[]` in an annotation).
|
|
176
|
+
if (t.strictEmpty)
|
|
177
|
+
out.strictEmpty = t.strictEmpty;
|
|
178
|
+
if (t.optionalFrom !== undefined)
|
|
179
|
+
out.optionalFrom = t.optionalFrom;
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
case 'TFun': {
|
|
183
|
+
const newParam = this.apply(t.param, _visited);
|
|
184
|
+
const newResult = this.apply(t.result, _visited);
|
|
185
|
+
if (newParam === t.param && newResult === t.result)
|
|
186
|
+
return t;
|
|
187
|
+
return { tag: 'TFun', param: newParam, result: newResult };
|
|
188
|
+
}
|
|
189
|
+
case 'TRecord': {
|
|
190
|
+
// Record types can participate in genuine object-reference cycles:
|
|
191
|
+
// assigning a constructor function onto a namespace record (e.g.
|
|
192
|
+
// `Ns.Make = (...) => Object.create(proto)` where `proto.constructor`
|
|
193
|
+
// points back at `Ns`) mutates the type graph into a loop. The TVar
|
|
194
|
+
// `visited` guard above cannot see such cycles, so also guard on
|
|
195
|
+
// object identity: re-entering a record that is already being
|
|
196
|
+
// substituted on this call stack returns it unchanged, preserving
|
|
197
|
+
// the cycle instead of recursing forever.
|
|
198
|
+
if (this.recordsInProgress.has(t))
|
|
199
|
+
return t;
|
|
200
|
+
this.recordsInProgress.add(t);
|
|
201
|
+
try {
|
|
202
|
+
const fields = {};
|
|
203
|
+
const src = t.fields;
|
|
204
|
+
for (const k in src) {
|
|
205
|
+
fields[k] = this.apply(src[k], _visited);
|
|
206
|
+
}
|
|
207
|
+
// Resolve label-keyed fields: when a label var resolves to a
|
|
208
|
+
// literal, the entry migrates to the string-keyed `fields` map.
|
|
209
|
+
// Entries whose label is still a variable stay in `labelFields`.
|
|
210
|
+
let labelFields;
|
|
211
|
+
if (t.labelFields && t.labelFields.length > 0) {
|
|
212
|
+
// Track which string keys were materialised *by this label pass* so
|
|
213
|
+
// that a later label resolving to the same key deep-merges with the
|
|
214
|
+
// earlier label's value (e.g. `{ [k]::[String] }` ⊕ `{ [k]::[Number] }`
|
|
215
|
+
// → `[String | Number]`) instead of first-wins dropping the second.
|
|
216
|
+
// A collision with an *original* concrete field still keeps the
|
|
217
|
+
// concrete value (caller-provided beats label-polymorphic placeholder).
|
|
218
|
+
const fromLabel = new Set();
|
|
219
|
+
for (const lf of t.labelFields) {
|
|
220
|
+
const lbl = this.apply(lf.label, _visited);
|
|
221
|
+
const ty = this.apply(lf.type, _visited);
|
|
222
|
+
if (lbl.tag === 'TLabel' && lbl.kind === 'lit') {
|
|
223
|
+
if (!(lbl.value in fields)) {
|
|
224
|
+
fields[lbl.value] = ty;
|
|
225
|
+
fromLabel.add(lbl.value);
|
|
226
|
+
}
|
|
227
|
+
else if (fromLabel.has(lbl.value)) {
|
|
228
|
+
fields[lbl.value] = (0, types_1.deepMergeTypes)(fields[lbl.value], ty);
|
|
229
|
+
}
|
|
230
|
+
// else: collides with an original concrete field → concrete wins.
|
|
231
|
+
}
|
|
232
|
+
else if (lbl.tag === 'TLabel') {
|
|
233
|
+
if (!labelFields)
|
|
234
|
+
labelFields = [];
|
|
235
|
+
labelFields.push({ label: lbl, type: ty });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (!t.rest) {
|
|
240
|
+
// Structural sharing: closed record with no label resolution and
|
|
241
|
+
// no changed field types → return the original.
|
|
242
|
+
if (!labelFields && !(t.labelFields && t.labelFields.length > 0)) {
|
|
243
|
+
let unchanged = true;
|
|
244
|
+
for (const k in src) {
|
|
245
|
+
if (fields[k] !== src[k]) {
|
|
246
|
+
unchanged = false;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (unchanged)
|
|
251
|
+
return t;
|
|
252
|
+
}
|
|
253
|
+
const out = { tag: 'TRecord', fields };
|
|
254
|
+
if (t.alias)
|
|
255
|
+
out.alias = t.alias;
|
|
256
|
+
if (t.strictEmpty)
|
|
257
|
+
out.strictEmpty = t.strictEmpty;
|
|
258
|
+
if (t.pickedFrom)
|
|
259
|
+
out.pickedFrom = t.pickedFrom;
|
|
260
|
+
if (t.defaultProjection)
|
|
261
|
+
out.defaultProjection = true;
|
|
262
|
+
if (t.fieldSchemes)
|
|
263
|
+
out.fieldSchemes = t.fieldSchemes;
|
|
264
|
+
if (t.fieldDisplays)
|
|
265
|
+
out.fieldDisplays = t.fieldDisplays;
|
|
266
|
+
if (t.hiddenFields)
|
|
267
|
+
out.hiddenFields = t.hiddenFields;
|
|
268
|
+
if (labelFields)
|
|
269
|
+
out.labelFields = labelFields;
|
|
270
|
+
return out;
|
|
271
|
+
}
|
|
272
|
+
// Open record: substitute the row variable. The row may resolve
|
|
273
|
+
// to another record (whose fields get spliced in alongside its
|
|
274
|
+
// own row), or remain a TVar (still open), or be bound to a
|
|
275
|
+
// TCon like Object/StrMap (treated as a closed tail).
|
|
276
|
+
const restApplied = this.apply(t.rest, _visited);
|
|
277
|
+
if (restApplied.tag === 'TVar' || restApplied.tag === 'TRow') {
|
|
278
|
+
const same = restApplied === t.rest;
|
|
279
|
+
if (same && !labelFields) {
|
|
280
|
+
// No change at all → return original to preserve referential equality.
|
|
281
|
+
const unchangedFields = Object.keys(fields).every(k => fields[k] === src[k]);
|
|
282
|
+
const sameLabelCount = (t.labelFields?.length ?? 0) === 0;
|
|
283
|
+
if (unchangedFields && sameLabelCount)
|
|
284
|
+
return t;
|
|
285
|
+
}
|
|
286
|
+
const out = { tag: 'TRecord', fields, rest: restApplied };
|
|
287
|
+
if (t.alias)
|
|
288
|
+
out.alias = t.alias;
|
|
289
|
+
if (t.pickedFrom)
|
|
290
|
+
out.pickedFrom = t.pickedFrom;
|
|
291
|
+
if (t.defaultProjection)
|
|
292
|
+
out.defaultProjection = true;
|
|
293
|
+
if (t.fieldSchemes)
|
|
294
|
+
out.fieldSchemes = t.fieldSchemes;
|
|
295
|
+
if (t.fieldDisplays)
|
|
296
|
+
out.fieldDisplays = t.fieldDisplays;
|
|
297
|
+
if (t.hiddenFields)
|
|
298
|
+
out.hiddenFields = t.hiddenFields;
|
|
299
|
+
if (t.mergeRow)
|
|
300
|
+
out.mergeRow = t.mergeRow;
|
|
301
|
+
if (labelFields)
|
|
302
|
+
out.labelFields = labelFields;
|
|
303
|
+
return out;
|
|
304
|
+
}
|
|
305
|
+
if (restApplied.tag === 'TRecord') {
|
|
306
|
+
// Splice: combine our fields with the inner record's fields,
|
|
307
|
+
// and adopt its row variable (if any). Conflicting keys keep
|
|
308
|
+
// *our* binding — it represents the more constrained side — UNLESS
|
|
309
|
+
// this row was flagged `mergeRow` (a label-group spread-merge such
|
|
310
|
+
// as `({ [k]::a }, {...b}) -> { [k]::a, ...b }`), in which case
|
|
311
|
+
// overlapping keys are DEEP-merged so the two contributions combine
|
|
312
|
+
// (`likedTypes::[String]` ⊕ `likedTypes::[Number]` → `[String | Number]`).
|
|
313
|
+
const merged = { ...restApplied.fields };
|
|
314
|
+
for (const k of Object.keys(fields)) {
|
|
315
|
+
merged[k] = (t.mergeRow && k in merged)
|
|
316
|
+
? (0, types_1.deepMergeTypes)(merged[k], fields[k])
|
|
317
|
+
: fields[k];
|
|
318
|
+
}
|
|
319
|
+
const mergedLabels = [
|
|
320
|
+
...(restApplied.labelFields ?? []),
|
|
321
|
+
...(labelFields ?? []),
|
|
322
|
+
];
|
|
323
|
+
const out = { tag: 'TRecord', fields: merged };
|
|
324
|
+
if (restApplied.rest) {
|
|
325
|
+
out.rest = restApplied.rest;
|
|
326
|
+
// Keep deep-merging if the spliced tail is itself still open.
|
|
327
|
+
if (t.mergeRow)
|
|
328
|
+
out.mergeRow = true;
|
|
329
|
+
}
|
|
330
|
+
if (t.alias)
|
|
331
|
+
out.alias = t.alias;
|
|
332
|
+
if (t.pickedFrom)
|
|
333
|
+
out.pickedFrom = t.pickedFrom;
|
|
334
|
+
if (t.defaultProjection)
|
|
335
|
+
out.defaultProjection = true;
|
|
336
|
+
if (t.fieldSchemes || restApplied.fieldSchemes) {
|
|
337
|
+
out.fieldSchemes = { ...(restApplied.fieldSchemes ?? {}), ...(t.fieldSchemes ?? {}) };
|
|
338
|
+
}
|
|
339
|
+
if (t.fieldDisplays || restApplied.fieldDisplays) {
|
|
340
|
+
out.fieldDisplays = { ...(restApplied.fieldDisplays ?? {}), ...(t.fieldDisplays ?? {}) };
|
|
341
|
+
}
|
|
342
|
+
if (t.hiddenFields || restApplied.hiddenFields) {
|
|
343
|
+
out.hiddenFields = new Set([
|
|
344
|
+
...(restApplied.hiddenFields ?? []),
|
|
345
|
+
...(t.hiddenFields ?? []),
|
|
346
|
+
]);
|
|
347
|
+
}
|
|
348
|
+
if (mergedLabels.length > 0)
|
|
349
|
+
out.labelFields = mergedLabels;
|
|
350
|
+
return out;
|
|
351
|
+
}
|
|
352
|
+
// TCon (e.g. Object) or TFun in row position: just close the row.
|
|
353
|
+
const closed = { tag: 'TRecord', fields };
|
|
354
|
+
if (t.alias)
|
|
355
|
+
closed.alias = t.alias;
|
|
356
|
+
if (t.pickedFrom)
|
|
357
|
+
closed.pickedFrom = t.pickedFrom;
|
|
358
|
+
if (t.defaultProjection)
|
|
359
|
+
closed.defaultProjection = true;
|
|
360
|
+
if (t.fieldSchemes)
|
|
361
|
+
closed.fieldSchemes = t.fieldSchemes;
|
|
362
|
+
if (t.fieldDisplays)
|
|
363
|
+
closed.fieldDisplays = t.fieldDisplays;
|
|
364
|
+
if (t.hiddenFields)
|
|
365
|
+
closed.hiddenFields = t.hiddenFields;
|
|
366
|
+
if (labelFields)
|
|
367
|
+
closed.labelFields = labelFields;
|
|
368
|
+
return closed;
|
|
369
|
+
}
|
|
370
|
+
finally {
|
|
371
|
+
this.recordsInProgress.delete(t);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
case 'TLabel': {
|
|
375
|
+
if (t.kind === 'lit')
|
|
376
|
+
return t;
|
|
377
|
+
const resolved = this.map.get(t.id);
|
|
378
|
+
if (!resolved)
|
|
379
|
+
return t;
|
|
380
|
+
if (resolved.tag === 'TLabel') {
|
|
381
|
+
if (resolved.kind === 'lit')
|
|
382
|
+
return resolved;
|
|
383
|
+
// Chase label-var chain
|
|
384
|
+
if (resolved.kind === 'var' && resolved.id === t.id)
|
|
385
|
+
return t;
|
|
386
|
+
const visited = _visited ?? new Set();
|
|
387
|
+
if (visited.has(t.id))
|
|
388
|
+
return t;
|
|
389
|
+
visited.add(t.id);
|
|
390
|
+
return this.apply(resolved, visited);
|
|
391
|
+
}
|
|
392
|
+
// Defensive: a non-label value bound to a label var → keep the label.
|
|
393
|
+
return t;
|
|
394
|
+
}
|
|
395
|
+
case 'TRow': {
|
|
396
|
+
// Row variables share the TVar id space; if a row binding exists,
|
|
397
|
+
// follow the chain. A row can resolve to another row, or to a
|
|
398
|
+
// TRecord (carrying its own fields/rest), or remain free.
|
|
399
|
+
const resolved = this.map.get(t.id);
|
|
400
|
+
if (!resolved)
|
|
401
|
+
return t;
|
|
402
|
+
if (resolved.tag === 'TRow' && resolved.id === t.id)
|
|
403
|
+
return t;
|
|
404
|
+
const visited = _visited ?? new Set();
|
|
405
|
+
if (visited.has(t.id))
|
|
406
|
+
return t;
|
|
407
|
+
visited.add(t.id);
|
|
408
|
+
return this.apply(resolved, visited);
|
|
409
|
+
}
|
|
410
|
+
case 'TForall': {
|
|
411
|
+
// Bound vars are globally fresh and never unified, so they can never
|
|
412
|
+
// appear in the substitution — applying to the body only touches the
|
|
413
|
+
// FREE (outer) variables occurring under the quantifier.
|
|
414
|
+
const newBody = this.apply(t.body, _visited);
|
|
415
|
+
if (newBody === t.body)
|
|
416
|
+
return t;
|
|
417
|
+
return { ...t, body: newBody };
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/** Compose: apply `other` first, then `this`.
|
|
422
|
+
*
|
|
423
|
+
* Uses lazy composition — TVar references in `other`'s entries are kept
|
|
424
|
+
* as-is instead of being eagerly resolved. This allows retroactive
|
|
425
|
+
* updates to TVar bindings (e.g. auto-union) to propagate through all
|
|
426
|
+
* entries that still reference the updated TVar. The `apply()` method
|
|
427
|
+
* follows chains dynamically, so the end result is identical.
|
|
428
|
+
*/
|
|
429
|
+
compose(other) {
|
|
430
|
+
const result = new Substitution();
|
|
431
|
+
// Keep other's mappings as-is (lazy — apply() chases chains on demand)
|
|
432
|
+
for (const [id, type] of other.map) {
|
|
433
|
+
result.map.set(id, type);
|
|
434
|
+
}
|
|
435
|
+
// Add our own mappings (these take precedence for ids not in other)
|
|
436
|
+
for (const [id, type] of this.map) {
|
|
437
|
+
if (!result.map.has(id)) {
|
|
438
|
+
result.map.set(id, type);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* In-place merge: absorb bindings from a (typically small) delta
|
|
445
|
+
* substitution into this (typically large) substitution.
|
|
446
|
+
*
|
|
447
|
+
* Equivalent to `this = delta.compose(this)` but avoids copying the
|
|
448
|
+
* entire map. Only the new ids from `delta` are inserted.
|
|
449
|
+
*
|
|
450
|
+
* This is the hot-path optimisation for `unifyWithDiagnostic`: `unify`
|
|
451
|
+
* returns a small delta (1-3 entries) while the engine substitution
|
|
452
|
+
* can have hundreds of entries — copying all of them on every unify
|
|
453
|
+
* call is unnecessary.
|
|
454
|
+
*/
|
|
455
|
+
mergeFrom(delta) {
|
|
456
|
+
for (const [id, type] of delta.map) {
|
|
457
|
+
if (!this.map.has(id)) {
|
|
458
|
+
this.map.set(id, type);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/** Get all entries. */
|
|
463
|
+
entries() {
|
|
464
|
+
return this.map.entries();
|
|
465
|
+
}
|
|
466
|
+
toString() {
|
|
467
|
+
const parts = [];
|
|
468
|
+
for (const [id, type] of this.map) {
|
|
469
|
+
parts.push(`t${id} => ${(0, types_1.typeToString)(type)}`);
|
|
470
|
+
}
|
|
471
|
+
return `{ ${parts.join(', ')} }`;
|
|
472
|
+
}
|
|
473
|
+
// -------------------------------------------------------------------------
|
|
474
|
+
// Branch-isolated substitution helpers
|
|
475
|
+
// -------------------------------------------------------------------------
|
|
476
|
+
/** Snapshot the current substitution state (shallow copy of all bindings). */
|
|
477
|
+
snapshot() {
|
|
478
|
+
return new Map(this.map);
|
|
479
|
+
}
|
|
480
|
+
/** Restore substitution to a previous snapshot, removing any bindings added since. */
|
|
481
|
+
restore(snap) {
|
|
482
|
+
this.map = new Map(snap);
|
|
483
|
+
}
|
|
484
|
+
/** Return bindings added or changed since the snapshot. */
|
|
485
|
+
diff(snap) {
|
|
486
|
+
const diff = new Map();
|
|
487
|
+
for (const [id, t] of this.map) {
|
|
488
|
+
const old = snap.get(id);
|
|
489
|
+
if (!old || old !== t) {
|
|
490
|
+
// Skip TVar→TVar bindings: they represent "same type as"
|
|
491
|
+
// relationships within a branch's context. Carrying them across
|
|
492
|
+
// branches would cause unrelated concrete constraints (e.g.
|
|
493
|
+
// res("foemp") constraining a to String) to propagate backwards
|
|
494
|
+
// through the TVar chain to variables that should stay free
|
|
495
|
+
// (e.g. e.leader).
|
|
496
|
+
if (t.tag === 'TVar')
|
|
497
|
+
continue;
|
|
498
|
+
diff.set(id, t);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return diff;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Merge bindings from two if/else branches.
|
|
505
|
+
* - If only one branch bound a TVar, apply that binding.
|
|
506
|
+
* - If both branches bound the same TVar to different concrete types,
|
|
507
|
+
* create a union.
|
|
508
|
+
* - If both branches bound it to the same type, just apply it.
|
|
509
|
+
*/
|
|
510
|
+
mergeBranches(consBindings, altBindings) {
|
|
511
|
+
// Apply bindings unique to each branch
|
|
512
|
+
for (const [id, t] of consBindings) {
|
|
513
|
+
if (!altBindings.has(id)) {
|
|
514
|
+
this.map.set(id, t);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
for (const [id, t] of altBindings) {
|
|
518
|
+
if (!consBindings.has(id)) {
|
|
519
|
+
this.map.set(id, t);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
// For TVars bound in both branches, merge
|
|
523
|
+
for (const [id, consT] of consBindings) {
|
|
524
|
+
const altT = altBindings.get(id);
|
|
525
|
+
if (!altT)
|
|
526
|
+
continue; // already handled above
|
|
527
|
+
const rCons = this.apply(consT);
|
|
528
|
+
const rAlt = this.apply(altT);
|
|
529
|
+
// Same resolved type — just apply either
|
|
530
|
+
if (rCons.tag === rAlt.tag && rCons.tag === 'TCon' && rAlt.tag === 'TCon' &&
|
|
531
|
+
rCons.name === rAlt.name && rCons.args.length === rAlt.args.length) {
|
|
532
|
+
this.map.set(id, consT);
|
|
533
|
+
}
|
|
534
|
+
else if ((0, typeUtils_1.isUnionable)(rCons) && (0, typeUtils_1.isUnionable)(rAlt)) {
|
|
535
|
+
// Different concrete types — create union
|
|
536
|
+
this.map.set(id, (0, typeUtils_1.mergeUnion)(rCons, rAlt));
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
// One or both are TVars or complex — just apply the consequent's
|
|
540
|
+
this.map.set(id, consT);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
exports.Substitution = Substitution;
|
|
546
|
+
//# sourceMappingURL=substitution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"substitution.js","sourceRoot":"","sources":["../../src/hm/substitution.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,yDAAyD;AACzD,EAAE;AACF,0CAA0C;AAC1C,8EAA8E;AAC9E,mEAAmE;AACnE,0EAA0E;AAC1E,mEAAmE;AACnE,EAAE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,EAAE,IAAA,sBAAU,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACN,iEAAiE;gBACjE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA/dD,oCA+dC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Type, Scheme } from './types';
|
|
2
|
+
export declare class TypeParseError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parse a Hindley-Milner type signature string into a `Scheme`.
|
|
7
|
+
*
|
|
8
|
+
* Examples:
|
|
9
|
+
* "Number -> String"
|
|
10
|
+
* "a -> a"
|
|
11
|
+
* "[Number] -> Number"
|
|
12
|
+
* "(Number -> String) -> Boolean"
|
|
13
|
+
* "Box a" (juxtaposition type application)
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseTypeSignature(input: string, constraintVarNames?: Iterable<string>, typeArities?: Map<string, number>): Scheme;
|
|
16
|
+
/**
|
|
17
|
+
* Parse a type signature, returning only the `Type` (discarding quantifiers).
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseType(input: string): Type;
|
|
20
|
+
export interface MethodTypeSignature {
|
|
21
|
+
/** The receiver type, e.g. `Box a` */
|
|
22
|
+
receiver: Type;
|
|
23
|
+
/** The method's type, e.g. `(a -> b) -> Box b` */
|
|
24
|
+
methodType: Type;
|
|
25
|
+
/** Full scheme (vars shared between receiver and method) */
|
|
26
|
+
scheme: Scheme;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse a method type signature with `~>` syntax.
|
|
30
|
+
*
|
|
31
|
+
* Example: "Box a ~> (a -> b) -> Box b"
|
|
32
|
+
* Returns: { receiver: Box<a>, methodType: (a -> b) -> Box<b> }
|
|
33
|
+
*
|
|
34
|
+
* @param constraintVarNames Optional set of type variable names that should
|
|
35
|
+
* be treated as higher-kinded (constraint) variables. This allows parsing
|
|
36
|
+
* `f a ~> ...` where `f` is a constraint type variable.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseMethodTypeSignature(input: string, constraintVarNames?: Iterable<string>, typeArities?: Map<string, number>): MethodTypeSignature;
|
|
39
|
+
//# sourceMappingURL=typeParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeParser.d.ts","sourceRoot":"","sources":["../../src/hm/typeParser.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,IAAI,EAA+B,MAAM,EAAyO,MAAM,SAAS,CAAC;AA0J3S,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAS5B;AAqoCD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAsBlI;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE7C;AAMD,MAAM,WAAW,mBAAmB;IAClC,sCAAsC;IACtC,QAAQ,EAAE,IAAI,CAAC;IACf,kDAAkD;IAClD,UAAU,EAAE,IAAI,CAAC;IACjB,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,EACrC,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,mBAAmB,CAoCrB"}
|