Skip to content

Commit

Permalink
Hot fix for Tag.hide
Browse files Browse the repository at this point in the history
  • Loading branch information
OAGr committed Jan 9, 2024
1 parent edd9f7c commit 9085694
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/squiggle-lang/__tests__/library/tag_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 13 additions & 7 deletions packages/squiggle-lang/src/fr/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,22 @@ type PickByValue<T, ValueType> = NonNullable<
>
>;

const booleanTagDefs = (tagName: PickByValue<ValueTagsType, boolean>) => [
const booleanTagDefs = <T>(
tagName: PickByValue<ValueTagsType, boolean>,
frType: FRType<T>
) => [
makeDefinition(
[frWithTags(frArray(frAny())), frBool],
frWithTags(frArray(frAny({ genericName: "A" }))),
[frWithTags(frType), frBool],
frWithTags(frType),
([{ value, tags }, tagValue]) => ({
value,
tags: tags.merge({ [tagName]: tagValue }),
}),
{ 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 }),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -304,7 +307,10 @@ Here is more text.
] `,
],
displaySection: "Tags",
definitions: booleanTagDefs("notebook"),
definitions: booleanTagDefs(
"notebook",
frArray(frAny({ genericName: "A" }))
),
}),
maker.make({
name: "getNotebook",
Expand Down

3 comments on commit 9085694

@vercel
Copy link

@vercel vercel bot commented on 9085694 Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 9085694 Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 9085694 Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.