Updates builtin type Map so that it stores Maybes in its nodes.#743
Merged
nicolas-abril merged 2 commits intoHigherOrderCO:mainfrom Dec 26, 2024
Merged
Updates builtin type Map so that it stores Maybes in its nodes.#743nicolas-abril merged 2 commits intoHigherOrderCO:mainfrom
nicolas-abril merged 2 commits intoHigherOrderCO:mainfrom
Conversation
nicolas-abril
requested changes
Dec 7, 2024
Member
nicolas-abril
left a comment
There was a problem hiding this comment.
Why are you changing the Map type? You didn't even mention that in the PR.
Also please update the PR name to something more succint, its a bit confusing.
I'm not against having Bool in the prelude, but we don't really need it for anything builtin.
tests/snapshots/encode_pattern_match__match_adt_unscoped_lambda.bend.snap
Outdated
Show resolved
Hide resolved
In-Veritas
added a commit
to In-Veritas/Bend
that referenced
this pull request
Dec 16, 2024
nicolas-abril
requested changes
Dec 16, 2024
src/fun/builtins.bend
Outdated
| return (unreachable(), map) | ||
|
|
||
| # Checks if a node has a value on a given key, returning Maybe/Some if it does, Maybe/None otherwise | ||
| def Map/get_check (map: Map(T), key: u24) -> (Map(T), Maybe(T)): |
Member
There was a problem hiding this comment.
get_check is not a great name. I prefer get_checked but it's also not great.
nicolas-abril
requested changes
Dec 18, 2024
src/fun/builtins.bend
Outdated
| return (unreachable(), map) | ||
|
|
||
| # Checks if a node has a value on a given key, returning Maybe/Some if it does, Maybe/None otherwise | ||
| def Map/get_check (map: Map(T), key: u24) -> (Map(T), Maybe(T)): |
nicolas-abril
requested changes
Dec 20, 2024
nicolas-abril
requested changes
Dec 20, 2024
Member
nicolas-abril
left a comment
There was a problem hiding this comment.
I'll trust the tests are correct
Member
|
I think a new Rust version is messing with the checks, I'll fix it don't worry |
Member
|
Can you rebase and try again? |
…as the Maybe type Updates builtin type Map so that it stores Maybes in its nodes. Implement builtin type Map, and its corresponding functions, as well as the Maybe type Updates builtin type Map so that it stores Maybes in its nodes. Changes made on 09-12-2024, includes fixing requests from HigherOrderCO#743 Fixes based on PR review Partially updates doc and follows requests from PR review Fixes documentation, makes tests return simpler values, deletes useless snapshot Removes map_tests.bend.snap
nicolas-abril
approved these changes
Dec 26, 2024
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
The following updates have been made to
builtins.bend:New/Updated Types and Functions
1.
Maybe2.
MapUpdated type definition:
Now, every
Nodestores aMaybetype to explicitly represent the presence or absence of a value.Updated/added functions:
Maybe/unwrap: Retrieves the value inside Maybe/SomeMap/set: Inserts or updates a value in the map.Map/get: Retrieves a value from the map, returning aMaybetype.Map/map: Applies a function to each value in the map.Map/contains: Checks whether a key exists in the map.Map/get_check: Retrieves a value and performs additional validation.Why remove unreachable() from Map nodes?
unreachable()function incorrectly ignores type check and can often cause bugs where the type isn't checked for an entire branch altogether.*does not tell you whether you merely hit an unused node, or if another function called unreachable().Tests
Documentation update
Partially updates documentation adding a section for the Maybe type and new Map functions