[Haskell-beginners] an observation about Haskell vs. Python
es at ertes.de
Thu Sep 20 04:43:07 CEST 2012
Dennis Raddle <dennis.raddle at gmail.com> wrote:
> Haskell creates compile-time error messages that are somewhat hard to
> understand for beginners.
> One reason for the weird (to a beginner) compile errors in Haskell is
> its expressivity -- almost any sequence of identifiers could
> potentially mean something, and if you make a mistake, the compiler is
> sure to find some "weird" way to interpret it.
I think the main source of weird error messages is Haskell's support for
type classes. Remember all those compiler's complaints about missing
instances? Those are probably the most confusing ones for beginners:
main = print (sin + 3)
You just forgot the argument to sin, for which an appropriate error
message would be something like "missing argument" or "first argument of
(+) is not a number". Of course the former is impossible in Haskell
because of currying. The latter would be possible, if Haskell wouldn't
have type classes (you would get a regular type mismatch). Instead you
get two missing instance errors:
No instance for (Show (a0 -> a0))
arising from a use of `print'
No instance for (Num (a0 -> a0))
arising from a use of `+'
I think that this problem cannot be solved, but one possible improvement
is for the compiler to print suggestions taken from a database.
Something along the lines of:
Notice: You probably forgot to apply `sin' to an argument.
However, I think that no work is done on that, and there is another
possible path: An average Haskell tutorial should always include a
section on understanding error messages. In fact the latest issue of
The Monad Reader  has an article on that by Jan Stolarek.
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Beginners