Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename and re-organize primitive operators #1937

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

yannham
Copy link
Member

@yannham yannham commented Jun 3, 2024

Primitive operators haven't got much love, as opposed to user-facing interfaces like the stdlib, and they have grown organically since the beginning of the very first Nickel prototype. As a result, the naming is inconsistent, with several generations, both in the surface syntax of Nickel and internally in the Rust codebase.

This PR makes a cleaning pass on primitive operators, by:

  1. Use full worlds in the style of the current stdlib: str ->
    string, num -> number, etc.
  2. Introduce pseudo-namespaces: instead of str_foo and record_bar, we use / as a separator for categories. The previous examples become string/foo and record/bar. We don't use ., to make it clear that it's not a normal record access, but just a nice way to dinstinguish the different categories
  3. Align old operators on the current naming in the standard library.

This PR is mostly read for review, but in order to appease the CI, I need to update the tree-sitter grammar first to accommodate for the / character in primops.

@github-actions github-actions bot temporarily deployed to pull request June 3, 2024 17:23 Inactive
@yannham yannham added this to the Next Minor (1.7) milestone Jun 4, 2024
@yannham yannham marked this pull request as ready for review June 6, 2024 10:03
@yannham
Copy link
Member Author

yannham commented Jun 6, 2024

Although this PR is also blocked on the topiary-queries update (tweag/topiary#708), it's in reviewable state.

@yannham yannham requested review from jneem and vkleen June 6, 2024 11:48
@yannham yannham force-pushed the refactor/primop-better-names branch from 7f139b9 to fd78dfd Compare June 7, 2024 09:16
@yannham yannham enabled auto-merge June 7, 2024 09:16
@github-actions github-actions bot temporarily deployed to pull request June 7, 2024 09:18 Inactive
@yannham yannham force-pushed the refactor/primop-better-names branch from fd78dfd to 8fead1c Compare June 7, 2024 09:20
@github-actions github-actions bot temporarily deployed to pull request June 7, 2024 09:23 Inactive
@yannham yannham force-pushed the refactor/primop-better-names branch from 8fead1c to c1be53e Compare June 7, 2024 09:31
@github-actions github-actions bot temporarily deployed to pull request June 7, 2024 09:34 Inactive
Primitive operators haven't got much love, as opposed to user-facing
interfaces like the stdlib, and they have grown organically since the
beginning of the very first Nickel prototype. As a result, the naming is
inconsistent, with several generations, both in the surface syntax of
Nickel and internally in the Rust codebase.

This PR makes a cleaning pass on primitive operators, by:

1. Use full worlds in the style of the current stdlib: `str` ->
   `string`, `num` -> `number`, etc.
2. Introduce pseudo-namespaces: instead of `str_foo` and `record_bar`,
   we use `/` as a separator for categories. The previous examples
   become `string/foo` and `record/bar`. We don't use `.`, to make it
   clear that it's not a normal record access, but just a nice way to
   dinstinguish the different categories
3. Align old operators on the current naming in the standard library.
@yannham yannham force-pushed the refactor/primop-better-names branch from c1be53e to 0d45fb6 Compare June 7, 2024 11:07
@github-actions github-actions bot temporarily deployed to pull request June 7, 2024 11:10 Inactive
@yannham yannham added this pull request to the merge queue Jun 7, 2024
Merged via the queue into master with commit 4c29726 Jun 7, 2024
5 checks passed
@yannham yannham deleted the refactor/primop-better-names branch June 7, 2024 11:33
github-merge-queue bot pushed a commit that referenced this pull request Jul 10, 2024
* clean up outdated primitive operator names

PR #1937 recently renamed many primitive operators. It missed some
instances of the previous names, though. In particular:

- error messages
- comments
- an unused function "apply_contract" in core/src/term/mod.rs

While most of these names were only made obsolete in #1937, some of them
have been incorrect for longer, eg "%array_access%" in
core/src/term/pattern/compile.rs and "recordMap" in core/src/term/mod.rs.

I caught as many as I could find. However it's hard to be sure I got all
of them, given that some of the previous names are very general terms
like "value", "fields", "length", and "map".

The full list of renames I identifiend are as follows, formatted as
"<old name> <new name>".

First, the easy cases:

    chng_pol label/flip_polarity
    record_map record/map
    str_trim string/trim
    str_chars string/chars
    str_uppercase string/uppercase
    str_lowercase string/lowercase
    str_length string/length
    str_from to_string
    num_from number/from_string
    enum_from enum/from_string
    str_is_match string/is_match
    str_find string/find
    str_find_all string/find_all
    record_empty_with_tail record/empty_with_tail
    label_push_diag label/push_diag
    enum_unwrap_variant enum/unwrap_variant
    enum_is_variant enum/is_variant
    enum_get_tag enum/get_tag
    apply_contract contract/apply
    array_lazy_app_ctr contract/array_lazy_app
    record_lazy_app_ctr contract/record_lazy_app
    elem_at array/at
    str_split string/split
    str_contains string/contains
    record_insert record/insert
    record_insert_with_opts record/insert_with_opts
    record_remove record/remove
    record_remove_with_opts record/remove_with_opts
    label_with_message label/with_message
    label_with_notes label/with_notes
    label_append_note label/append_note
    str_replace string/replace
    str_replace_regex string/replace_regex
    str_substr string/substr
    record_seal_tail record/seal_tail
    record_unseal_tail record/unseal_tail
    array_slice array/slice

Then the harder cases:

    polarity label/polarity
    go_dom label/go_dom
    go_codom label/go_codom
    go_array label/go_array
    go_dict label/go_dict
    embed enum/embed
    map array/map
    generate array/generate
    length array/length
    fields record/fields
    fields_with_opts record/fields_with_opts
    values record/values
    go_field label/go_field
    has_field record/has_field
    has_field_with_opts record/has_field_with_opts
    field_is_defined record/field_is_defined
    field_is_defined_with_opts record/field_is_defined_with_opts
    lookup_type_variable label/lookup_type_variable
    insert_type_variable label/insert_type_variable

Finally, two cases that I didn't understand and seem to be unused:

    rec_force_op op rec_force
    rec_default_op op rec_default

* address code review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants