Make Set and Map finite, add ISet and IMap.#2486
Draft
jaylorch wants to merge 167 commits into
Draft
Conversation
added 30 commits
October 16, 2025 12:18
Collaborator
Author
|
Oh, I just realized I haven't made it possible to have a recursive type |
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.
Set<A>andMap<A>now represent finite sets and maps, respectively.ISet<A>andIMap<A>are the new names for the old-style possibly-infinite sets and maps.This new design is motivated because (1) it allows recursive types, such as having an
enum Twith aSet<T>field; and (2) finite sets are quite common in user code, and it's easy to go down a wild goose chase trying to get an ambient broadcast property to instantiate that turns out to be a missing.finite().The simplest porting path for existing code is to use the infinite versions, which work like the previous single Set and Map. Replace Set with ISet, Map with IMap,
set!withiset!, andmap!withimap!.To exploit the finite sets, use the Set and Map types. Where you might have specified a set domain with a predicate (boolean closure) before, now you might start with a finite constructor and transform it with map or filter.
Or, even better, use the recently added
set_build!macro to produce a finite set. To produce a finite map, construct the finite domain as aSetand use it as the first parameter to the newMap::new.This PR addresses issue #1512.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.