3 ms·
Somewhat related: What has blown my mind at some point is that with dependent types you can actually check your algorithms for correctness. --- Example: http:
by fho 5y ago
Somewhat related: What has blown my mind at some point is that with dependent types you can actually check your algorithms for correctness.
---
Example: http://goto.ucsd.edu:8090/index.html#?demo=Order.hs http://goto.ucsd.edu:8090/index.html#?demo=Order.hs
Press Check -> The button should turn green and say "Safe"
Now mess up the algorithm, e.g. change the `>=` in line 174 to `<=` in effect changing the sorting order.
Press Check again -> The button should turn red and the line you changed should be highlighted telling you that at this point you violated the ordering constraint that put in place by the `IncrList a` type.
---
To be fair, I don't think too many programming work is low-level algorithmic programming where this would be applicable.
I see the benefits in having type level size constraints on arrays or having a "Safe / Unsafe" constraint on input from users that can only be changed by running through verification functions.
- bidirectional 5y agoThese are refinement types, rather than dependent types. The main distinction as I understand it being that refinement types allow you to state assertions at a meta-level which are submitted to an SMT solver which may or may not prove them correct, dependent types on the other hand allow expression of arbitrary constraints within the types themselves, along with arbitrary proofs satisfying these types.
- fho 5y agoYeah ... I am no expert there. I would guess there is some overlap between refinement and dependent types, thou.