3 ms·
> trust that standard library designers aren't capriciously violating my expectations for what a Map is. You don't even need to trust them. The compiler checks
by nequo 4y ago
> trust that standard library designers aren't capriciously violating my expectations for what a Map is.
You don't even need to trust them. The compiler checks that their Map is the same as what you call a Map.
In the scenario that I am imagining, you have defined your data structures as types. You're looking for an algorithm to perform a particular transformation on your data. This transformation is from one data type to another, so you know the "type signature" of the algorithm. If the algorithm is already implemented, then you can find it with typed holes or Hoogle. If it doesn't exist yet, you can write it.
Rob Pike's Rule 5 says that if your types are good, it will be self-evident what functions to use to transform them.
- lolinder 4y ago> You don't even need to trust them. The compiler checks that their Map is the same as what you call a Map. Sort of. I think the person I was replying to was indicating that the implementation could be wrong and still match the type signature. As a simple example, `insert` could return the exact same Map object as was passed in (rather than one that has the key updated) and still match the type signature of `insert`. On the whole you're right, because if your standard data structures are that bad you should really be using a different language, not choosing to ignore types because they might not be helpful this time.