Seth Kurtzberg seth at cql.com
Wed Nov 21 15:19:21 EST 2007

-----Original Message-----
From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-users-bounces at haskell.org] On Behalf Of Wolfgang Jeltsch
Sent: Wednesday, November 21, 2007 10:32 AM
To: glasgow-haskell-users at haskell.org
Subject: Re: if-them_else

Am Mittwoch, 21. November 2007 15:03 schrieb Serge D. Mechveliani:
> Dear GHC developers,
> when compiling the function   f x = if x them False else True
> ghc-8.8.1  reports:   " parse error on input `else' ".
> When there is a large expession after `them', it is sometimes
> difficult to locate a typo.
> Why does not it report  " parsing if-then-else: cannot find `then' "
> ?
> Regards,

them is a perfect identifier.  So probably x them False gets parsed as an 
expression (x applied to them and the result applied to False).  Haskell’s 
lightweight syntax makes programs short and easy to read (in my opinion) but 
it often makes the compiler unable to guess where your mistake lies.

That means that the compiler does not know about the error at the time the "them" token is parsed.  It doesn't imply that the error message cannot be better.  In this case, since the compiler, indeed, detects the error at the token "else", it should be straightforward to improve the error message.

Now, whether it is worth the effort is a separate question, and a judgement call, but it is surely possible and not even terribly difficult.

Seth Kurtzberg
Software Engineer
Specializing in Security, Reliability, and the Hardware/Software Interface

Best wishes,
Glasgow-haskell-users mailing list
Glasgow-haskell-users at haskell.org

More information about the Glasgow-haskell-users mailing list