|
|
|
|
|
by blacktriangle
1782 days ago
|
|
So you're saying without dependent types you can express in a type a function that will return double each element in the list thus removing the need to test the function? If you can do that, that's awesome, but I'm not seeing how. |
|
As for a function that will "double" a list, i.e. turn [1,2] into [1,1,2,2]: That is definitely possible with dependent types as they can express arbitrary statements. I'm not sure if you can do it without dependent types, but I'm inclined to say yes: something like an HList should work. Universal quantification over the HList parameters will ensure that the only way to create new values of the parameter types is to copy the old ones, as long as you disallow any form of `forall a. () -> a` in the type system.
Something like this, which is just the `double` function lifted into the universe of types, _might_ work, though its utility is questionable: