if-them_else

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

if-them_else

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,

-----------------
Serge Mechveliani
[hidden email]
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

RE: if-them_else

sethk
Maybe it's from Chicago and doesn't see anything wrong with "them" in that
context.  :)

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Serge D.
Mechveliani
Sent: Wednesday, November 21, 2007 9:04 AM
To: [hidden email]
Subject: if-them_else

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,

-----------------
Serge Mechveliani
[hidden email]
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: if-them_else

Wolfgang Jeltsch-2
In reply to this post by Serge D. Mechveliani
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.

Best wishes,
Wolfgang
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

RE: if-them_else

sethk


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Wolfgang Jeltsch
Sent: Wednesday, November 21, 2007 10:32 AM
To: [hidden email]
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,
Wolfgang
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users