Comments (11)
That is because TR's set code was written before mutable sets existed.
Splitting out HashTable
might be useful, but I'm not sure if you would want to split out ImmutableHashTable
or ReadableHashTable
. The first gets you the flat contracts/predicates, the second gets you covariance. Nothing gets you required explicit mutability because you can just revert to HashTable
and not specify it.
Sets get more complicated because there are also generic sets which TR still doesn't support.
from typed-racket.
@shekari Could you explain the typing difference between immutable hash tables and readable hash tables? Why wouldn't they be equivalent?
from typed-racket.
from typed-racket.
@samth Oh, I see, that makes sense. ImmutableHashTable
would still get you covariance, though, yes?
Wouldn't having explicit mutability still be helpful, though? Contracts support it, and then hash-set!
and friends would be checked statically rather than at runtime. Though I suppose it wouldn't be backwards-compatible.
from typed-racket.
Yes, all of these things would be good ideas, and I think we could make everything compatible.
from typed-racket.
Should we fork HashTable
into ReadableHashTable
, ImmutableHashTable
, and MutableHashTable
? Then just leave HashTable
as-is? It would make HashTable
a sort of silly type to use for anything, but I guess that's the price to pay for compatibility.
Then w.r.t. Set
, should we make it analogous to the new HashTable
types?
from typed-racket.
HashTable
would be a supertype of the other types.
I think the story for Set
is less obvious. It's not clear that supporting more without supporting generic sets is useful.
from typed-racket.
With Set
, I think we need to at least support mutable hash sets. I ran into this originally when trying to use mutable hash sets in typed code, and the support for them currently simply doesn't exist. Obviously we wouldn't be able to support generic sets, but I think mutable sets are still a pretty valid use case.
from typed-racket.
Sure, if there's need, we should support it. I think we should just split Set
and MutableSet
though.
from typed-racket.
You mean make Set
and MutableSet
entirely disparate types, like Pair
and MPair
? I think having the type structure of the proposed hash table rework would be nice.
from typed-racket.
In a perfect world, I think ReadableHashTable
would be the supertype (and we could just call it HashTable
), and ImmutableHashTable
and MutableHashTable
would be subtypes. You'd get flat contracts with Immutable
, mutability with Mutable
, and covariance with Readable
and Immutable
.
I don't think this is possible while maintaining backwards-compatibility, though. Should we keep HashTable
around as a legacy type and add Readable
/Immutable
/Mutable
in parallel?
from typed-racket.
Related Issues (20)
- for loop fails to infer subtype.
- Examples of unexpected behavior for integer refinements
- `AnyValues` in `let/cc` is unbound.
- The `Nothing` type causes the type checker not to check the type. HOT 2
- struct #:mutable field option
- any-wrap: avoid wrapping immutable structs with immutable fields HOT 3
- Strange lack of subtyping for `case->` HOT 1
- Constructors in `typed/web-server/http` not provided
- Weird Error Message from `require/typed`
- apply < doesn't accept a non-empty list
- `check-eq? (hasheq) (hasheq)` fails HOT 4
- TR unsound with keyword args HOT 2
- `struct`'s `#:methods` missing in Typed Racket HOT 3
- The new hash match pattern doesn't work in Typed Racket
- type mismatch when using `Float`s with `for/sum` HOT 1
- `require/typed/provide` not providing constructors
- `require/typed` yields "unused require" warnings
- TR fails to typecheck when using optional arg and inline type specs
- treelists not supported in Typed Racket
- Can't use #:property to seal a Typed Racket structs
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 typed-racket.