Comments (8)
Hi @anacrolix . The problem was that SortedMap requires constraints.Ordered
, and there's so much code shared between Map and SortedMap that it was dramatically more straightforward to use constraints.Ordered for both.
Maybe it's not the best approach long-term, but Ben seemed happy with this for now..
Unless there's something I'm missing - maybe I am - I think you'd need to duplicate all the map-related types like Hasher, defaultHasher, MapIterator, mapEntry, mapNode, mapValueNode, mapLeafNode, mapArrayNode, MapBuilder, ... there's a lot of types in there. Hopefully there's some opportunities to avoid some of the duplication, but it's an undertaking - feel free to take it on.
At least you know why it is like it is now :)
from immutable.
I don't have a strong opinion on any of this—mostly because I haven't done much with generics. If anybody has a good solution then I'm open to it but I haven't had time to commit to the immutable
project lately.
from immutable.
I definitely don't have the time to dedicate to this right now. It's used in the old and obsoleted STM concurrency implementation in anacrolix/dht that I think only gets dredged up because of golang/go#55955.
from immutable.
@anacrolix I had a quick experiment with widening the constraint for immutable.Map. Does it help?
from immutable.
I will give it a go and report back, thank you @laher !
from immutable.
I gave it a spin, it didn't work for the underlying user (although the stm code passed). I think the type can be widened for SortedMap (and any other variants too). Again, because comparers are manually given, the restriction on types belong to those implementations. I'm pretty sure it works for the builtin comparers too, as those use type sets to check for orderable types anyway. Short answer: I think K comparable
can be used everywhere in immutable.
from immutable.
Short answer: I think
K comparable
can be used everywhere in immutable.
Good shout - I think it should be OK, just needing a bit of jiggery-pokery on the defaultComparer.
from immutable.
Let me know if you do that change, and I'll report back. Thanks @laher
from immutable.
Related Issues (19)
- Split the monolithic file into three separate files, one per data structure HOT 1
- Hasher for byte array HOT 1
- Feature Request: Allow to append/prepend multiple values HOT 2
- Feature Request: Delete List element HOT 2
- Add efficient list builder
- Feature Request: Make datastructures as Interface
- Generics? HOT 2
- Higher-order procedures HOT 3
- Add efficient map builder
- List - varargs for Append, NewList, Prepend HOT 1
- Set/SortedSet types HOT 3
- deprecate/remove Builders HOT 2
- Add efficient sorted map builder
- Why ImmutableList of size 7 occupies 128 bytes? HOT 2
- SortedSetBuilder Doesn't Have a Mechanism To Return The Set HOT 1
- Allow Creating Immutable Builders (Map/SortedSet/List) intialised with initial Values
- Consider changing immutable types such as List[T] and Map[T] to use by-value semantics instead of by-reference
- Objects stored in maps are not stored as copies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immutable.