Re: [racket-users] Typed Racket needs annotation to realize (Mutable-HashTable Symbol Symbol) is of a more general type

2019-11-06 Thread Marc Kaufmann
Thanks Alexis, I now see why the subtyping doesn't work and why mutability is the issue. So when using mutable data structures, I really have to use the largest possible type everywhere or add annotations or similar - making types on immutable data more flexible. That's interesting. Thanks for

Re: [racket-users] Typed Racket needs annotation to realize (Mutable-HashTable Symbol Symbol) is of a more general type

2019-11-06 Thread Ben Greenman
On 11/6/19, Marc Kaufmann wrote: > I assumed it was something to do with mutability, but I don't understand > what you mean when you say there is a two-way channel. The reference in > typed racket ( >

Re: [racket-users] Typed Racket needs annotation to realize (Mutable-HashTable Symbol Symbol) is of a more general type

2019-11-06 Thread Alexis King
The point Sam is making is about the variance of Mutable-HashTable specifically. Its relationship to the HashTable supertype is a red herring (which is why changing the type to Mutable-HashTable didn’t help). Immutable data structures, like lists and immutable hash tables, are covariant in

Re: [racket-users] Typed Racket needs annotation to realize (Mutable-HashTable Symbol Symbol) is of a more general type

2019-11-05 Thread Marc Kaufmann
I assumed it was something to do with mutability, but I don't understand what you mean when you say there is a two-way channel. The reference in typed racket (

Re: [racket-users] Typed Racket needs annotation to realize (Mutable-HashTable Symbol Symbol) is of a more general type

2019-11-05 Thread Sam Tobin-Hochstadt
The problem is that the `DB` type is _not_ a super-type of `(Mutable-HashTable Symbol Symbol)`, because mutable data structures are two way communications channels. If you used an immutable hash, that's a one-way communication and you would have the expected result. However, the change you made

[racket-users] Typed Racket needs annotation to realize (Mutable-HashTable Symbol Symbol) is of a more general type

2019-11-05 Thread Marc Kaufmann
Hi, in order to put some discipline on my code (and formalize to myself what I'm passing around), I started using typed racket. I have definitely hit my share of gotchas that make me scratch my head, but I kind of start to understand how things work and adding `(ann this-is ThatType)`