Generalise dataspace patterns to permit extensibility

This commit is contained in:
Tony Garnock-Jones 2024-04-04 15:52:43 +02:00
parent 29959c055e
commit 6b58ef9f0f
1 changed files with 4 additions and 4 deletions

View File

@ -13,7 +13,7 @@ export function classOfValue(v: any): Shape | null {
if (Record.isRecord(v)) {
return constructorInfoSignature(Record.constructorInfo(v));
} else if (Array.isArray(v)) {
return '' + v.length;
return '[]';
} else if (Dictionary.isDictionary(v)) {
return '{}';
} else {
@ -24,9 +24,9 @@ export function classOfValue(v: any): Shape | null {
export function classOfCtor(v: P.DCompound): Shape {
switch (v._variant) {
case 'rec':
return canonicalString(v.label) + '/' + v.fields.length;
return canonicalString(v.label);
case 'arr':
return '' + v.items.length;
return '[]';
case 'dict':
return '{}';
}
@ -34,7 +34,7 @@ export function classOfCtor(v: P.DCompound): Shape {
// Called by generated code in addition to functions in this module
export function constructorInfoSignature(ci: RecordConstructorInfo<Value>): string {
return canonicalString(ci.label) + '/' + ci.arity;
return canonicalString(ci.label);
}
export function step(v: AnyValue, index: AnyValue): AnyValue | undefined {