[Haskell-cafe] Haskell is a declarative language? Let's see how easy it is to declare types of things.
waldmann at imn.htwk-leipzig.de
Wed Apr 3 17:28:29 CEST 2013
I absolutely love to use Haskell when teaching
(and I have several years of experience doing it).
And I absolutely dislike it when I have to jump through hoops
to declare types in the most correct way, and in the most natural places.
This is hard to sell to the students. - Examples:
1. for explicit declaration of type variables, as in
reverse :: forall (a :: *) . [a] -> [a]
I have to switch on RankNTypes and/or KindSignatures (ghc suggests).
C'mon, this has nothing to do with ranks per se.
It's a type of a very simple function!
IMHO even Java/C# do this better (with slightly strange syntax,
but at least you get to declare the type variable).
2. for declaring types of local variables, as in
\ (xs :: [Bool]) -> ...
I have to enable PatternSignatures (actually ghc suggests
ScopedTypeVariables but again there is no type variable in sight)
I need to do this often, to disambiguate properties for Smallcheck.
All of this just because it seemed, at some time,
a clever idea to allow the programmer to omit quantifiers?
(I know, mathematicians do this all over the place,
but it is never helpful, and especially not when teaching.)
I think that (1) implies (2): there could be no ambiguity about scopes
(of typevars in patterns) if each typevar had to be introduced
by explicit quantification. Then (in a pattern signature)
a use could be distinguished from a declaration.
Yes, the above is a rant. I can achieve what I want with some ghc options,
and perhaps my point is that these should be on by default -
or have better names, because presently, they are unintelligible to the
More information about the Haskell-Cafe