From 9085694057614493a615fe706f880be6312a9b72 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Tue, 9 Jan 2024 12:45:16 -0800 Subject: [PATCH] Hot fix for Tag.hide --- .../__tests__/library/tag_test.ts | 4 ++++ packages/squiggle-lang/src/fr/tag.ts | 20 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/squiggle-lang/__tests__/library/tag_test.ts b/packages/squiggle-lang/__tests__/library/tag_test.ts index 52ef9ac594..3bc210d164 100644 --- a/packages/squiggle-lang/__tests__/library/tag_test.ts +++ b/packages/squiggle-lang/__tests__/library/tag_test.ts @@ -24,6 +24,10 @@ describe("Tags", () => { testEvalToBe("[123] -> Tag.notebook -> Tag.getNotebook", "true"); }); + describe("hide", () => { + testEvalToBe("3 -> Tag.hide -> Tag.getHide", "true"); + }); + describe("omit", () => { testEvalToBe( "123 -> Tag.name('myName') -> Tag.doc('myDoc') -> Tag.format('.2%') -> Tag.omit(['name', 'doc']) -> Tag.getAll", diff --git a/packages/squiggle-lang/src/fr/tag.ts b/packages/squiggle-lang/src/fr/tag.ts index 58c7b9847d..05a86aa2fb 100644 --- a/packages/squiggle-lang/src/fr/tag.ts +++ b/packages/squiggle-lang/src/fr/tag.ts @@ -64,10 +64,13 @@ type PickByValue = NonNullable< > >; -const booleanTagDefs = (tagName: PickByValue) => [ +const booleanTagDefs = ( + tagName: PickByValue, + frType: FRType +) => [ makeDefinition( - [frWithTags(frArray(frAny())), frBool], - frWithTags(frArray(frAny({ genericName: "A" }))), + [frWithTags(frType), frBool], + frWithTags(frType), ([{ value, tags }, tagValue]) => ({ value, tags: tags.merge({ [tagName]: tagValue }), @@ -75,8 +78,8 @@ const booleanTagDefs = (tagName: PickByValue) => [ { isDecorator: true } ), makeDefinition( - [frWithTags(frArray(frAny({ genericName: "A" })))], - frWithTags(frArray(frAny({ genericName: "A" }))), + [frWithTags(frType)], + frWithTags(frType), ([{ value, tags }]) => ({ value, tags: tags.merge({ [tagName]: true }), @@ -271,7 +274,7 @@ Different types of values can be displayed in different ways. The following tabl name: "hide", description: `Hides a value when displayed under Variables. This is useful for hiding intermediate values or helper functions that are used in calculations, but are not directly relevant to the user. Only hides top-level variables.`, displaySection: "Tags", - definitions: booleanTagDefs("hidden"), + definitions: booleanTagDefs("hidden", frAny({ genericName: "A" })), }), maker.make({ name: "getHide", @@ -304,7 +307,10 @@ Here is more text. ] `, ], displaySection: "Tags", - definitions: booleanTagDefs("notebook"), + definitions: booleanTagDefs( + "notebook", + frArray(frAny({ genericName: "A" })) + ), }), maker.make({ name: "getNotebook",