Modular implicits
-
-
Replying to @jckarter @slava_pestov
You could say that the way we line up witnesses to requirements and pass conformances around is a buggy, unspecified and incomplete implementation of implicits
2 replies 0 retweets 3 likes -
Replying to @jckarter
Yeah, but theoretically we could shake out all ad-hoc conformance lookups except those in the constraint solver. Maybe the main difficulty is with dynamic casts and not retroactive conformance per se? What *is* the equivalent of a cast in a functor world?
2 replies 0 retweets 1 like -
Replying to @slava_pestov
Dynamic casts are the only thing I can think of that fundamentally require global coherence. It should be possible everywhere else to choose conformances modularly, in the runtime model at least
1 reply 0 retweets 2 likes -
Replying to @jckarter
Do you think it’s possible to have a language construct that fulfills a similar need to dynamic casts but does not suffer from this problem?
1 reply 0 retweets 0 likes -
Replying to @slava_pestov @jckarter
It seems like, in theory, if you can attach “with regard to: <current module>” data implicitly during compilation to every dynamic cast that you achieve this.
1 reply 0 retweets 1 like -
Replying to @gregtitus @jckarter
That makes sense at compile time. But suppose I call some hypothetical stdlib function that casts an Any storing your Foo type to Hashable - it will do a lookup from the stdlib’s namespace and not see the Foo : Hashable conformance you added
3 replies 0 retweets 0 likes -
BTW, a very similar issue was why we dropped importable instances in Rust. We internally called it the “hash table problem” at the time :)
2 replies 0 retweets 4 likes -
In Swift we use conformances as part of the key for parameterizing types, so you’d get different hash table types if they grabbed different hashing implementations
2 replies 0 retweets 1 like -
We thought about doing something like that but decided against it because it seemed like it would have unknown ramifications. Figured it was better the devil you know (typeclasses)
3 replies 0 retweets 0 likes
I think I was the one who proposed to just do typeclasses with a no-orphan-instances check. Memory is a bit fuzzy.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.