RE: confusing error message

2003-02-06 Thread Simon Peyton-Jones
Good point.   Error message improved, regression test added.

Thanks for the suggestion

Simon

| -Original Message-
| From: Dean Herington [mailto:[EMAIL PROTECTED]]
| Sent: 05 February 2003 19:14
| To: [EMAIL PROTECTED]
| Subject: confusing error message
| 
| buzzard(118)% cat Bug5.hs
| import Control.Monad.State
| data S = S Int
| newtype M a = M (StateT S IO a)
|   deriving (Monad)
| 
| main = return ()
| buzzard(119)% ghc -c Bug5.hs
| 
| Bug5.hs:3:
| Can't make a derived instance of `Monad M'
| (too hard for cunning newtype deriving)
| When deriving instances for type `M'
| buzzard(120)% ghc --version
| The Glorious Glasgow Haskell Compilation System, version 5.04.2
| 
| 
| The real problem above is that I forgot to enable extensions.  It
would
| be helpful if the error message indicated that as the problem.
| 
| 
| ___
| Glasgow-haskell-bugs mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



Re: Confusing error message in case of layout-related syntax erro r

1999-09-03 Thread Mark Utting

Simon wrote:
 I know about this one, but haven't got around to fixing it yet.  The parse
 error is on a semicolon generated by the layout system, as you probably
 guessed, which is why there's no token available to print in the error
 message.  Any thoughts on what a suitable error message should be?  I'd
 thought something along the lines of
 
   Main.hs:3: parse error on input ';' (inserted by layout)

My students find this kind of error message (Hugs says "unexpected ';'")
the most confusing and frustrating thing in all of Haskelldom.

If you know that the (virtual) semicolon has been inserted by
layout, how about a message like:

Main.hs:3: indentation error
or
Main.hs:3: incorrect indentation
or
Main.hs:3: parse error due to incorrect indentation

(I think the term "indentation" means more to them than "layout",
 but there might be good reasons to say "layout error" instead).

Mark.

Dr Mark Utting, Senior Lecturer
Department of Computer Science
School of Computing and Mathematical Sciences
The University of Waikato   Tel:   +64 7 838 4791
Private Bag 3105Fax:   +64 7 838 4155
HamiltonEmail: [EMAIL PROTECTED]
New Zealand Web:   http://www.cs.waikato.ac.nz/~marku



RE: Confusing error message in case of layout-related syntax error

1999-09-03 Thread Malcolm Wallace

Main.hs:3: parse error on input ';' (inserted by layout)
  
   Incomplete expression on previous line or incorrect
   indentation of the current line.

I think Manuel's suggestion is a definite improvement here.

For interest, another Haskell compiler, nhc98, gives the message
4:5 Found ;' but expected one of ) ,
which is perhaps a little bit cryptic, but could be improved to
4:5 Found end-of-definition but expected one of ) ,
which I think is very clear.

Regards,
Malcolm



RE: Confusing error message in case of layout-related syntax erro r

1999-09-02 Thread Simon Marlow

 For 
 
   foo = let
 x = (1, 2
 y = 3
   in
   fst x + y
 
 GHC 4.04 gives me
 
   Main.hs:3: parse error on input `'
 
 Interesting, but not very informative ;-)

I know about this one, but haven't got around to fixing it yet.  The parse
error is on a semicolon generated by the layout system, as you probably
guessed, which is why there's no token available to print in the error
message.  Any thoughts on what a suitable error message should be?  I'd
thought something along the lines of

Main.hs:3: parse error on input ';' (inserted by layout)

re: the multi-line string literals, this one should be easier to fix.  I'll
take a look at it today.

Cheers,
Simon



Re: Confusing error message

1998-02-18 Thread Manuel Chakravarty

  I encountered a confusing error message, which you can
  reproduce with 
  
type P a = Maybe a
  
instance Monad P where
  (=)  = error "foo"
  return = error "bar"
  
  I get 
  
bug.hs:5: `P' should have 1 argument, but has been given 0 .
 
 Would it be better if it said 
 
   Type synonym constructor P should have 1 argument,
   but has been given 0
 
 Haskell requires that type synonyms are never partially applied;
 that's what's being complained about here.
 
 If you did fully apply it, GHC 3.1 (without -fglasow-exts) would
 then complain about making an instance of a type synonym.
 At the moment, though, it trips over the mal-formed type expression first.

That's what I guessed, but I reckon that it may be a bit
difficult to spot for people who are not so familiar with
the details of constructor classes.  But, maybe it is too
much fuzz to check for this special situation explicitly.

I wonder whether it would be helpful to add a comment like

  (or if this is a instance declaration, type synonyms are
  not allowed)

to the message.

Manuel



Re: Confusing error message

1998-02-17 Thread Simon L Peyton Jones

 
 I encountered a confusing error message, which you can
 reproduce with 
 
   type P a = Maybe a
 
   instance Monad P where
 (=)  = error "foo"
 return = error "bar"
 
 I get 
 
   bug.hs:5: `P' should have 1 argument, but has been given 0 .

Would it be better if it said 

Type synonym constructor P should have 1 argument,
but has been given 0

Haskell requires that type synonyms are never partially applied;
that's what's being complained about here.

If you did fully apply it, GHC 3.1 (without -fglasow-exts) would
then complain about making an instance of a type synonym.
At the moment, though, it trips over the mal-formed type expression first.

Does that make sense?  Any suggestions for improving the error
message in a way that would have made sense to you at the time?

Simon