From 6b58ef9f0f0619d343202a0cf021ff898e338dc8 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 4 Apr 2024 15:52:43 +0200 Subject: [PATCH] Generalise dataspace patterns to permit extensibility --- packages/core/src/runtime/pattern.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/runtime/pattern.ts b/packages/core/src/runtime/pattern.ts index 0178509..1d2c1de 100644 --- a/packages/core/src/runtime/pattern.ts +++ b/packages/core/src/runtime/pattern.ts @@ -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): string { - return canonicalString(ci.label) + '/' + ci.arity; + return canonicalString(ci.label); } export function step(v: AnyValue, index: AnyValue): AnyValue | undefined {