Re: [GHC] #2900: Confusing error message for monadic function with wrong number of arguments

2009-02-02 Thread GHC
#2900: Confusing error message for monadic function with wrong number of 
arguments
+---
Reporter:  tim  |Owner:  
Type:  bug  |   Status:  new 
Priority:  normal   |Milestone:  _|_ 
   Component:  Compiler (Type checker)  |  Version:  6.10.1  
Severity:  minor|   Resolution:  
Keywords:   |   Difficulty:  Unknown 
Testcase:   |   Os:  Unknown/Multiple
Architecture:  Unknown/Multiple |  
+---
Changes (by igloo):

  * milestone:  => _|_

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2900: Confusing error message for monadic function with wrong number of arguments

2008-12-29 Thread GHC
#2900: Confusing error message for monadic function with wrong number of 
arguments
+---
Reporter:  tim  |Owner:  
Type:  bug  |   Status:  new 
Priority:  normal   |Milestone:  
   Component:  Compiler (Type checker)  |  Version:  6.10.1  
Severity:  minor|   Resolution:  
Keywords:   |   Difficulty:  Unknown 
Testcase:   |   Os:  Unknown/Multiple
Architecture:  Unknown/Multiple |  
+---
Changes (by simonpj):

 * cc: chak (added)
  * difficulty:  => Unknown

Comment:

 Good example!  Sadly, it's quite awkward to fix.  Here's what is
 happening.

  * GHC tries to make the type `Int -> m ()` look like `ty1 -> ty2 -> ty3`
 (to match the syntactic form of the LHS.
  * It's ''possible'' that the context `(MonadIO m)` might have, as a
 "superclass" the equality `m ~ (->) Int`.  In that case we'd get `ty2 =
 Int`, `ty3 = ()`.
  * Because `m` might be elucidated by the context, GHC can't reject the
 result type `(m ())` right away.  Instead it invents a fresh type variable
 alpha, and generates the contraint that `(m ~ (->) alpha)`, leaving the
 constraint to be solved later.
  * Now we go on to the RHS, and that gives a type error.

 What we really want here is to solve the first constraint "eagerly", and
 proceed only if it succeeds.  The type checker isn't set up to do that at
 the moment, but this is an interesting example to bear in mind, thank you.

 Simon

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2900: Confusing error message for monadic function with wrong number of arguments

2008-12-26 Thread GHC
#2900: Confusing error message for monadic function with wrong number of 
arguments
-+--
Reporter:  tim   |  Owner: 
Type:  bug   | Status:  new
Priority:  normal|  Component:  Compiler (Type checker)
 Version:  6.10.1|   Severity:  minor  
Keywords:|   Testcase: 
  Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple   
-+--
 If I compile the following code:

 {{{
 import Control.Monad.State

 foo :: MonadIO m => Int -> m ()
 foo x y = return ()
 }}}

 I get the error message:

 {{{
 bug.hs:6:10:
 Couldn't match expected type `()' against inferred type `m ()'
 In the expression: return ()
 In the definition of `foo': foo x y = return ()
 }}}

 On the other hand, if I change foo's type signature to:
 {{{
 foo :: Int -> IO ()
 }}}
 I get the more helpful:
 {{{
 bug.hs:6:0:
 The equation(s) for `foo' have two arguments,
 but its type `Int -> IO ()' has only one
 }}}

 It would be good if the second error message appeared in the first case as
 well.

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs