RE: improving error messages

2006-10-30 Thread Simon Peyton-Jones
| as you may remember, in GHC survey awkward error messages was named as
| one of most serious GHC drawbacks. i propose to start collecting
| examples of bad error messages together with what we want to see in
| these cases. as first contribution, i've added this text as
| http://hackage.haskell.org/trac/ghc/ticket/956

Thank you!  It'll be very useful to have such a collection.  

Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


improving error messages

2006-10-21 Thread Bulat Ziganshin
Hello glasgow-haskell-users,

as you may remember, in GHC survey awkward error messages was named as
one of most serious GHC drawbacks. i propose to start collecting
examples of bad error messages together with what we want to see in
these cases. as first contribution, i've added this text as
http://hackage.haskell.org/trac/ghc/ticket/956 

the following program

main = do putChar 'a'
  putChar

makes this error message::

Couldn't match expected type `IO' against inferred type `(-) Char'
Probable cause: `putChar' is applied to too few arguments
In the expression: putChar


while the 'probable cause' is very helpful, the error message by
itself is hard to understand for novices. i propose in these cases to
work against known value types. in this case, we know that 'putChar'
has type 'Char - IO ()' and GHC may report smth like this:

'putChar': expression of type 'Char - IO ()' used in context that
requires expression of 'IO ()' type
Probably, you've omitted parameter of type 'Char' to this expression

comparing this with existing message shows that may be improved:

1) for me, it's still hard to understand what is expected and
inferred means. i guess that for true beginners it's even harder.
i prefer to see something more English and less Mathematic - it will
be very helpful

2) instead of obscure 'IO' and `(-) Char' types, i strongly prefer to
see more pragmatic 'IO ()' and 'Char - IO ()' ones

3) 'Probable cause' may be more pleasant by telling position and type
of skipped argument(s)



my second example is almost the same :)

main = do putChar
  putChar 'a'

in this case error message is even worser:

Couldn't match expected type `(-) Char' against inferred type `IO'
Probable cause: `putChar' is applied to too many arguments
In the expression: putChar 'a'

afaiu, here GHC thought that putChar should have 'IO ()' type. or, it
may think that operations in this monad has type 'Char - IO ()'.
anyway, it will be great if GHC will know that operations in monad
usually has type 'IO a' or 'm a' and try to use this heuristic when
dealing with such errors (different types of statements in 'do' block)

-- 
Best regards,
 Bulat  mailto:[EMAIL PROTECTED]

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: improving error messages

2000-03-31 Thread George Russell

(Sent to glasgow-haskell-users rather than haskell, as it is GHC-specific.)

If we were writing a C library rather than a Haskell library, we could make
"head" a macro which included an appropriate message referring to __FILE__
and __LINE__.  The equivalent in Glasgow Haskell would be to make head inline,
and include a primHaskellFile (and if possible, though I doubt it, primHaskellLine)
which got replaced at a late stage by the actual name of the current module.  This
would be useful for locating other error messages as well.  For example I have
a debug action which (if debugging is turned on) prints out messages to a file;
if we had a primHaskellFile I could make this debug message automatically refer
to the calling module, which would be nice.