Many users have experienced "my program is simple, but type system is so complex that I can't for the life of me get it to typecheck" which is .. a thing you want to reserve for only the gravest / most-pervasive problems if you want anyone to have the patience to use the thing.
Part of that is because when types feel "easy", it's possible to mentally elide them and focus on normal function execution. But type parameters require you to first run a "type interpreter" in your head to understand what you're looking at.
-
-
I think this is the explanation for why people have an intuition that parameters are existentials: it's much easier to avoid the "type interpreter" step when you think about them that way.
-
I think I (maybe like
@ubsanitizer) don't understand the mental model you're describing. I think about (and teach) type parameterization as a precise analogue of function parameterization. You have two similar things (functions, type defs), and you abstract by adding a parameter. -
Right, that's my mental model of type parameters. I know functions are really hard to "get" before you have the intuition; I imagine type parameters are the same way.
-
(but once you have that intuition, then you're fine)
-
I agree with this model, but do you agree that you first have to mentally instantiate the function with types before you can mentally instantiate it with parameters?
-
Only if you need to typecheck the function (perhaps if you need to do that in order to figure out what the function does in the first place because static types determine runtime behavior).
-
an earlier sub-thread in this chain stated (without objection) that a mismatch between parameter and existential intuitions is the source of problems. Did I misunderstand that? Can you elaborate?
-
The existential intuition is wrong, just like lots of wrong intuitions about functions are wrong. I think you said that people use the existential intuition because it's simpler, but I disagree that it's simpler than the abstraction intuition I described.
- 1 more reply
New conversation -
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.