3 ms·
I'm generally interested in this, but (even as somebody who knows intermediate Haskell), I don't have a good intuition about the scope of dependent types: - ho
by 2mol 6y ago
I'm generally interested in this, but (even as somebody who knows intermediate Haskell), I don't have a good intuition about the scope of dependent types:
- how much of the burden of writing the proof falls on me, and how much falls to the compiler? I've seen Idris type signatures, and I didn't find them super easy to grasp.
- What are the full range of things I can express? What can't I express, even with dependent types? I come from math, so I'm used to have infinite flexibility to define what goes into my set of possible values. When I first learned Haskell I was surprised that I couldn't easily define types like "this set, modulo an equivalence relation". Or something like: "Int, but only even numbers".
- how huch more effort falls to me when structuring my code, in order to pass the properties or proofs through? I already run into this all the time in Haskell, with Maybes thay I _know_ to contain a value, or Lists that I know not to be empty. There is a real trade off between writing clear code, and wrapping/unwrapping values all the time everywhere.
Length-indexed vectors is a great example, because it is such a non-story in math, and yet for programming I have to front-load all this complexity to express something so utterly trivial. It's part infuriating, part enlightening how surprisingly tricky seemingly small things can be.
- h-cobordism 6y ago> - how much of the burden of writing the proof falls on me, and how much falls to the compiler? The compiler in Idris can do some magic, but usually the burden is mostly on you to write proofs. Idris (and similar languages) have assistance in editors to help you automatically write code and proofs. > What are the full range of things I can express? Dependent types as present in Idris, Coq, Agda, etc. can serve as a foundation for mathematics, so… pretty much anything! For your example, most such languages don't have quotient types, so you'll still need to use setoids or similar to model quotients. > - how huch more effort falls to me when structuring my code, in order to pass the properties or proofs through? It's pretty much the same situation as Haskell or Rust, but I think having to write fromJust / unwrap is great. It tells you when you're reading the code exactly what assumption has been made, and it doesn't seem awfully burdensome. > yet for programming I have to front-load all this complexity to express something so utterly trivial. What's "all this complexity" that you're referring to?