3 ms·
"I'm superficially familiar with Haskell's typeclass system, but respectfully, this misses my point." I suggest becoming more than superficially familiar, then
by jerf 10y ago
"I'm superficially familiar with Haskell's typeclass system, but respectfully, this misses my point."
I suggest becoming more than superficially familiar, then. With all due respect, I believe your core problem is that you do not understand what advanced type systems can do, so it's a mystery to you why anybody would want them, and the only cure for that is to go learn. Again, let me emphasize, I do not mean this to be mean, but sometimes there's just no way around the problem in an HN-post sized reply.
I know one recurring thing I've encountered is that I'd love to be able to say that in
type Something interface {
DoWhatever() Something
}
that the return result of DoWhatever is guaranteed to be the same type as the thing you called it on. I'd love to be able to guarantee that if I have a container and a contained type that I can associate the two things together (i.e., I have a "Game" and "Move" interfaces and I'd like to associate specific Game implementations to specific Move implementations). I'd like containers that don't wrap everything in interface{}, resulting in an inefficient representation that is also hard to use in the code. I'd like non-nillable pointers.
On the balance I still use it for my job because the benefits outweigh the costs, but there are tradeoffs I make for it.
- omginternets 10y ago>I suggest becoming more than superficially familiar, then. It's a work in progress :) >With all due respect No offense taken > I know one recurring thing I've encountered is that I'd love to be able to say that in [...] that the return result of DoWhatever is guaranteed to be the same type as the thing you called it on Forgive me, but isn't this generics all over again, or am I missing something? And once more, is it possible to bake these features into the type system without requiring more boilerplate code? I like the idea of strong guarantees of a type system, but I worry about having to wrestle with the compiler. One of the things I really like about Go is that the type system provides guidance but I don't spend much time making the compiler accept things that I patently know are compatible (I'm looking at you, Rust).
- steveklabnik 10y agoI'd be interested in hearing more about your Rust pain here; we're working a lot on ergonomics and productivity.
- crzwdjk 10y agoIt's annoying to sometimes have to introduce artificial blocks just to make the borrow-checker happy. It sounds like there's going to be some work done on non-lexical lifetimes though, which would solve the more annoying of these problems.
- steveklabnik 10y agoHear you loud and clear, thanks!