progress
This commit is contained in:
parent
6af72e525c
commit
145835ad5d
22 changed files with 153 additions and 90 deletions
13
util.js
13
util.js
|
|
@ -1,3 +1,6 @@
|
|||
import { inspect } from 'node:util';
|
||||
import { symbolFunction, symbolList, symbolProduct, symbolSum } from './structures/types.js';
|
||||
|
||||
// re-inventing the wheel:
|
||||
export function deepEqual(a, b) {
|
||||
if (a === b) return true; // <- shallow equality and primitives
|
||||
|
|
@ -45,17 +48,17 @@ export class DefaultMap {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
import { inspect } from 'node:util';
|
||||
import { symbolFunction, symbolList, symbolProduct, symbolSum } from './structures/types.js';
|
||||
|
||||
export function pretty(obj) {
|
||||
return inspect(obj, {colors: true, depth: null});
|
||||
}
|
||||
|
||||
// Pretty print type
|
||||
export function prettyT(type) {
|
||||
if (type.typeVars) {
|
||||
return `∀${[...type.typeVars].map(prettyT).join(", ")}: ${prettyT(type.type)}`;
|
||||
if (type.typeVars.size > 0) {
|
||||
return `∀${[...type.typeVars].map(prettyT).join(", ")}: ${prettyT(type.type)}`;
|
||||
}
|
||||
return prettyT(type.type);
|
||||
}
|
||||
if (type.symbol === symbolFunction) {
|
||||
return `${prettyT(type.params[0])} -> ${prettyT(type.params[1])}`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue