Allow strip_binds in Pattern.drop_lit

This commit is contained in:
Tony Garnock-Jones 2024-05-29 17:37:01 +02:00
parent 4c3eaeff1c
commit ffea85ece9
1 changed files with 6 additions and 1 deletions

View File

@ -214,7 +214,7 @@ export function lit(v: AnyValue): P.Pattern {
return P.Pattern.lit(P.asAnyAtom(v));
}
export function drop_lit(p: P.Pattern): AnyValue | null {
export function drop_lit(p: P.Pattern, strip_binds = false): AnyValue | null {
const e = new Error();
function walkEntries(target: AnyValue[], entries: EncodableDictionary<Ref, AnyValue, P.Pattern<Ref>>): void {
@ -253,6 +253,11 @@ export function drop_lit(p: P.Pattern): AnyValue | null {
}
case 'lit':
return P.fromAnyAtom(p.value);
case 'bind':
if (strip_binds) {
return walk(p.pattern);
}
// fall through
default:
throw e;
}