Re:A Crash Course on ML Modules (2015)
by yen223 on Sunday February 25, 2018 @07:20PM
(#16462081)
"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.
Re:A Crash Course on ML Modules (2015)
by yorwba on Sunday February 25, 2018 @08:28PM
(#16462353)
Since 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.
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.