-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow `Nodes::Node`s to hold arbitrary `value`s! 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 `|| raise`s 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 `UnannotatedEmptyCollection`s - Raise `InvalidOperation`s when `compress(child)` return nil value which is not supposed to be possible
- Loading branch information
Showing
36 changed files
with
252 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
interface _Nilable | ||
def nil?: -> bool | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
module Rambling | ||
module Trie | ||
class Compressor | ||
def compress: (Nodes::Node?) -> Nodes::Compressed? | ||
class Compressor[TValue < _Inspect] | ||
def compress: (Nodes::Node[TValue]?) -> Nodes::Compressed[TValue]? | ||
|
||
private | ||
|
||
def compress_only_child_and_merge: (Nodes::Node) -> Nodes::Compressed | ||
def compress_only_child_and_merge: (Nodes::Node[TValue]) -> Nodes::Compressed[TValue] | ||
|
||
def merge: (Nodes::Node, Nodes::Node) -> Nodes::Compressed | ||
def merge: (Nodes::Node[TValue], Nodes::Node[TValue]) -> Nodes::Compressed[TValue] | ||
|
||
def compress_children_and_copy: (Nodes::Node) -> Nodes::Compressed | ||
def compress_children_and_copy: (Nodes::Node[TValue]) -> Nodes::Compressed[TValue] | ||
|
||
def compress_children: (Hash[Symbol, Nodes::Node]) -> Hash[Symbol, Nodes::Node] | ||
def compress_children: (Hash[Symbol, Nodes::Node[TValue]]) -> Hash[Symbol, Nodes::Node[TValue]] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.