3 ms·
"In OCaml, if you have a value of type `sorted`, you know it's indeed sorted." Could you expand on this? I'm pretty sure the OCaml compiler isn't sophisticated
by yen223 9y ago
"In OCaml, if you have a value of type `sorted`, you know it's indeed sorted."
Could you expand on this? I'm pretty sure the OCaml compiler isn't sophisticated enough to make guarantees like this - i.e. I could pass in a function that satisfies the interface constraints, but doesn't actually do any sorting.
- yorwba 9y agoSince the function import in the signature is the only way to create a value of the abstract type sorted, and the implementation of import is given as Array.sort, all values of type sorted have indeed been sorted.