
On Mon, 2008-08-04 at 19:51 +0100, Brian Hulley wrote:
Hi, I'm familiar with the capitalization rules for identifiers in Haskell and know that they are very useful and practical e.g. by allowing variables to be distinguished from "constants" in patterns etc.
However I'm trying to understand on a much deeper level whether or not they can really be justified and indeed if there is a danger that they can lead to inconsistency in the light of future extensions to the language.
For example, why is there any distinction between a type "variable" and a type "constant"?
To make this clearer consider the type of (map):
(a -> b) -> List a -> List b
(ignoring the special [] syntax for list types which would just confuse the issue here).
With explicit quantifiers, we'd write:
forall a b. (a -> b) -> List a -> List b
Now this begs the question: why does "List" need to start with a capital? (supposing that quantifiers were always written explicitly)
AFAIK, it doesn't; the variable/constant distinction is just there to let the implementation put the foralls in for you. Similarly, if we had explicit foralls on equations, we could say forall n x xn. drop (n+1) (x:xn) = drop n xn but forall n. drop n nil = nil and it would be perfectly clear that `nil' in the latter case was a constructor. Of course, if you want to introduce this rule, you'd better start out with it and be consistent --- require every variable to be explicitly brought into scope. I think you'd find it pretty annoying after trying to program in your new language for a while, though. jcc