by Tainnor · 4y ago · 0 comments
However, it's still based on Idris 1 (which didn't have QTT). The basics haven't changed much though (some examples have to be modified slightly, mostly related to making some arguments explicit that used to be implicit).
Idris seems like a really interesting language. Examples from the book include:
- typesafe printf (it will check that the correct number of arguments with the correct types are passed at compile time).
- proving that functions are total (roughly that means that they terminate for every input)
- writing infinitely running programs as a stream of actions, meaning that the majority of the program can be written as a total function and only the top-level function actually consuming the actions needs to be partial
- views with dependent pattern matching for traversing structures safely in several ways
- safe division
- ability to define all the effects your system uses instead of using an unrestricted IO type
etc.
While the examples are super interesting I don't think that I yet fully grasp all the possible things you could do with dependent types (or what sorts of limitations they have). I guess that would come with more practice.
For example, it seems like Idris doesn't really support subtyping unless I've missed something obvious (you can use typeclasses, but that doesn't allow you to use heterogeneous collections or anything). I believe it's also a requirement that all functions used in type signatures are total.
Yes of course. All languages have specific syntax and semantics. That doesn’t change the fact that you can encode all of math in it which is a huge deal. It allows you to prove code correct (see CompCert, seL4, CertOS etc.)
And yes you can’t prove anything unless the functions you use are total. That’s a basic requirement for any language where you want to use the type system to prove correct code. Allowing non-total functions would allow you to prove false. And you can prove anything you want from false.
But in terms of practical developments, these "restrictions" can matter. Especially when you have specific maintenance concerns. And I'm talking more about programming than theorem proving (Idris is, after all, more geared towards the former than the latter unlike e.g. Coq or Lean).
I've had a problem in the back of my head for a while and I knew it would probably be a bit cumbersome to do in Haskell (although maybe with some advanced extensions it's possible?). I thought that dependent types might solve that problem but I yet don't see a way how I could do that, at least in Idris (possibly I'm missing out on some very obvious way). I think I'd really need subtyping to make it work in a non-cumbersome way. (Or else, possibly some code generation for the boilerplate part.)