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

Allow Nodes::Nodes to hold arbitrary values #85

Merged
merged 10 commits into from
Dec 8, 2024

Conversation

gonzedge
Copy link
Owner

@gonzedge gonzedge commented Dec 8, 2024

Allow Nodes::Nodes to hold arbitrary values! Now, you can have a terminal node that on top of representing its word, it can hold on to

  • Add value attribute to Nodes::Node
  • Add optional, nilable value argument to Container#add, Nodes::Node#add
  • Store given value in terminal node via Nodes::Raw#add and Nodes::Raw#add_to_children_tree, when present
  • Update Compressor#merge and Compressor#compress_children_and_copy to store value from Nodes::Raw in the
    terminal Nodes::Compressed, when present
  • Add optional values array argument to Container#concat corresponding 1:1 to words, that passes each word and
    value to #add when present
  • Add value to Inspectable#inspect output, when present
  • Add generic type TValue to Nodes::Node type signature
    • Extract _Nilable interface to own top-level file
    • Make value attribute in Nodes::Node use the new TValue generic type
    • Allow TValue to be nil by default with ?
    • Require TValue to implement _Inspect built-in(!) interface, for Inspectable module
    • Change all types that depend on Nodes::Node also have the generic type TValue < _Inspect
      including static methods
    • Add optional TValue argument to Container#add, Nodes::Node#add, and Nodes::Raw#add_to_children_tree
    • Add optional Array[TValue?] argument to Container#concat
    • Add new || raises because the inline type conversion to non-nil doesn't work anymore for steep check 🤷🏻‍♂
  • Make compatible with rbs v3.7.0 and steep v1.9.0
    • Change ProviderCollection#[] to return TProvider?
    • Change Nodes::Node#[] to return Nodes::Node[TValue]?
    • Change Container#[] to return Nodes::Node[TValue]?
    • Add type annotations for UnannotatedEmptyCollections
    • Raise InvalidOperations when compress(child) return nil value which is not supposed to be possible

@gonzedge gonzedge force-pushed the gonzedge/trie-nodes-with-arbitrary-values branch from 50684fa to 063fd26 Compare December 8, 2024 04:14
- `Nodes::Node#value`
- `Container#add` and `Container#concat`; updated the `add_word` spec helpers.
- `Compressor#compress`
- Add `value` attribute to `Nodes::Node` with new `TValue` type
- Allow `TValue` to be `nil` by default with `?`
- Require `TValue` to implement `_Inspect` built-in(!) interface, for
  `Inspectable` module
- Change all types that depend on `Nodes::Node` also have the generic type
  `TValue < _Inspect` including static methods
- Add optional `TValue` argument to `Container#add`, `Nodes::Node#add`, and
  `Nodes::Raw#add_to_children_tree`
- Add optional `Array[TValue?]` argument to `Container#concat`
- Add new `|| raise`s because the inline type conversion to non-nil doesn't
  work anymore 🤷🏻‍♂️
@gonzedge gonzedge force-pushed the gonzedge/trie-nodes-with-arbitrary-values branch from 063fd26 to e196071 Compare December 8, 2024 04:16
- Change `ProviderCollection#[]` to return TProvider?
- Change `Nodes::Node#[]` to return Nodes::Node[TValue]?
- Change `Container#[]` to return Nodes::Node[TValue]?
- Add type annotations for `UnannotatedEmptyCollection`s
- Raise `InvalidOperation`s when `compress(child)` return nil value which is not supposed to be possible
Copy link

codeclimate bot commented Dec 8, 2024

Code Climate has analyzed commit b9fcac1 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (95% is the threshold).

This pull request will bring the total coverage in the repository to 100.0% (0.0% change).

View more on Code Climate.

@gonzedge gonzedge merged commit e62bbee into main Dec 8, 2024
30 checks passed
@gonzedge gonzedge deleted the gonzedge/trie-nodes-with-arbitrary-values branch December 8, 2024 22:48
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.

1 participant