[nhc-bugs] Nit: File Parsing Error Messages

Olaf Chitil olaf@cs.york.ac.uk
Wed, 30 May 2001 20:21:12 +0100


Brent Fulgham wrote:
> 

> add :: Integer -> Integer -> Integer
> add x y = x + y
> 
>   inc   = add 1
> -- ^^^ Indented two spaces


> 8:9 Found = but expected a {-EOF-}

This error message is independent of the operating system, you get it on
any system.

The error message is definitely rather terse (I guess {- EOF -} means
end of file although end of function definition would be more
appropriate).

Nonetheless, the message makes sense: because `inc' is indented, nhc
thinks that it belongs to the right hand side of the previous
definition. Basically it reads it as if you had written

add x y = x + y inc = add 1

Hence complaining about `=' makes sense.

Producing better error messages by guessing what the programmer meant is
always prone to error and may lead to even more confusion. So for
example you could also have meant to write

add x y = x + y
  where
  inc = add 1

This seems unlikely, because `inc' is not used on the right hand side of
the definition of `add'. But what if it had been used there?

However, you are certainly right in that we should try to improve nhc's
error messages.

Cheers,
Olaf


-- 
OLAF CHITIL, 
 Dept. of Computer Science, University of York, York YO10 5DD, UK. 
 URL: http://www.cs.york.ac.uk/~olaf/
 Tel: +44 1904 434756; Fax: +44 1904 432767