Trying to make that work for static validation requires dependent typing: the type of the result depends on the term passed in. Or, you could use row types, record types, or any of the other data structures richly typed languages use at their core to be more expressive of intent than just a Map from Any to Any.
I can't decide to use the PHP type system for some of my program then the Haskell type system elsewhere I can't combine them they're infectious they don't preserve well over the wire
They're often used for more than one purpose suboptimally
I'm either in 100% agreement with the language's type system or I'm unhappy in some aspects and so I'm unhappy with the language
People seem to choose their languages more on the type system than more fundamental aspects of their language
I think what most users want is static analysis and they don't understand how that is different from a type system they just assume you have to have a type system for static analysis
There's also no conversation about how complex a type system should be to support static analysis in fact some type systems are full blown turing complete
I think there's a more interesting conversation to be had around correctness in a collaborative environment that we're not having at large because type systems exist and consume the conversations
So language developers continue finding the perfect one that is a million little choices working together that must be perfect for everyone
It's a itch that will never be satisfied
For the reasons explored in the post, I prefer my type systems optional. It has been my experience and observation that typing in languages follow an 90:10 rule. You get 90% of the gains for 10% of the effort. And the remaining 10% for 9x the effort.
I’m rather happy with the way Python allows me to do the easy ones and/or pick the hotspots.
I’ve worked in exhaustively typed languages, and while it gives a sense of safety, it’s literally exhausting. And, anecdotally, I feel I dealt with more zero divides, subscript woops, and other runtime validation errors than I had in less typed languages.
Not that it matters. Soon, we’ll use semantically vague human language, to prompt, cajole, nudge LLM agents to produce programs that are (lossy) statistical approximations of what might be correct programs.
The difference is that Enum is maybe a total function - the domain of the function is always well defined, while Map take is trying to be dressed up as a total function but its really something thats only partial.
So the type system needs a way to describe a map that has "at least these keys" a bit like the enum case. So that requires some polymorphism.
I mean, if you define a function calling Map.take! that returns one of two possible set of keys based on a random number, I’m not sure it’s actually possible to get a map where you’re certain what keys exist.