Skip to content

Commit

Permalink
Update the documentation to reflect that [..] is now overloaded for…
Browse files Browse the repository at this point in the history
… sets

Summary: The `[..]` syntax now works for both arrays and sets. Update the documentation to prefer this syntax. Mark the `elements` construct as deprecated.

Differential Revision: D68765862

fbshipit-source-id: 3504dcf737e03c03772dee5a326659ecebbdc3bb
  • Loading branch information
Josef Svenningsson authored and facebook-github-bot committed Jan 28, 2025
1 parent 4037f78 commit 1487c09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions glean/website/docs/angle/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,21 +496,21 @@ If we want to know for a particular file and a particular name, where it is used

```lang=angle
XRefsViaNameByFile { file = "foo.py", xrefs = XRefs };
{ target = { name = "Bar" } } = elements XRefs
{ target = { name = "Bar" } } = XRefs[..]
```

The second line uses the construct `elements` which is similar to the `[..]` syntax for arrays.
The second line uses the `[..]` syntax which works the same as for arrays, each element of the set `XRefs` is produced as a different result.

We can also create new sets from the results of a query. This is done using the `all` construct. For instance
`all (1 | 2 | 3)` is a set containing the number `1`, `2`, and `3`.

The `all` construct can be used in combination with the `elements` construct to, for instance, map over a set
The `all` construct can be used in combination with the `[..]` construct to, for instance, map over a set
of elements and transform them. In the example below, the second line takes each element of the `StringSet` and
applies the primitive `prim.toLower` to it. The result is a set where all the strings are lowercase.

```lang=angle
StringSet = all ("Foo" | "Bar" | "Baz" );
all (String = elements StringSet; prim.toLower String)
all (String = StringSet[..]; prim.toLower String)
```

## String prefix
Expand Down
4 changes: 2 additions & 2 deletions glean/website/docs/angle/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Terms have the following forms:
  *term* `[..]`

> All the elements of the array **term**
> All the elements of **term**, which is either an array or a set.
  *term₁* `|` *term₂*

Expand All @@ -93,7 +93,7 @@ Terms have the following forms:
  `elements` *term*

> All the elements of the set **term**
> **Deprecated**, use the `[..]` syntax above. All the elements of the set **term**
  `all` *query*

Expand Down

0 comments on commit 1487c09

Please sign in to comment.