|
|
|
|
|
by chriswarbo
1619 days ago
|
|
> The more abstract parts like dependent types are really complicated and even unintuitive to use. I disagree with this: dependent types are way easier than lots of the convoluted schemes that non-dependent languages have come up with. As a simple example, dependently-typed languages don't need parametric polymorphism or generics: we can achieve the same thing by passing types as arguments; e.g. map: (inType: Type) -> (outType: Type) -> (f: inType -> outType) -> (l: List inType) -> List outType
map inType outType f l = match l with
Nil inType -> Nil outType
Cons inType x xs -> Cons outType (f x) (map inType outType f xs)
When I program without dependent types, I regularly find myself getting "stuck" inadvertently; knowing that (a) there's no way to make my current approach work in this language, (b) that it would be trivial to make it work if I could pass around types as values, (c) that I need to throw away what I've done and choose a different solution, and (d) the alternative solution I'll end up with will be less correct and less direct than my original approach (e.g. allowing more invalid states) |
|