[Haskell-beginners] an observation about Haskell vs. Python

Ertugrul Söylemez 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 [1] has an article on that by Jan Stolarek.

[1]: http://themonadreader.files.wordpress.com/2012/08/issue20.pdf


Greets,
Ertugrul

-- 
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...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120920/136f8756/attachment-0001.pgp>


More information about the Beginners mailing list