#5296: Compile succeeds without signature, but fails with the signature 
suggested
by GHC
----------------------------------------+-----------------------------------
    Reporter:  dsf                      |        Owner:                         
  
        Type:  bug                      |       Status:  new                    
  
    Priority:  normal                   |    Milestone:  7.4.1                  
  
   Component:  Compiler (Type checker)  |      Version:  7.0.3                  
  
    Keywords:                           |     Testcase:                         
  
   Blockedby:  1897                     |   Difficulty:                         
  
          Os:  Linux                    |     Blocking:                         
  
Architecture:  x86_64 (amd64)           |      Failure:  GHC rejects valid 
program
----------------------------------------+-----------------------------------

Comment(by simonpj):

 The problem here is related to #1897, as you point out, but is even
 clearer because it doesn't even involve type families.  The trouble is
 this.  `method` has type
 {{{
 method :: C t1 t2 m => Int -> m t2
 }}}
 Notice that `t1` does not appear in `method`'s type.  Now GHC is faced
 with
 {{{
 From   given  (C t1 t2 m)
 deduce wanted (C t3 t2 m)
 }}}
 Notice the t3.   The call of `method` means that the second and third args
 of C must be t2, m; but the first can be anything.  So type inference is
 supposed to guess what type it should use for t3.  Here there is a unique
 choice, but in general it is hard to solve problems where there is are
 ''positive'' clues, only that there is just one magic solution.

 If we could supply the type arguments to the call to `method`, we could
 say this:
 {{{
 f :: forall t1 t2 (m :: * -> *). C t1 t2 m => Int -> m t2
 f x = method @t1 @t2 @m x
 }}}
 Here I put the type args with a leading "@" (the notation I'm currently
 considering for type args).  Now we'd be fine.

 In short, the only Decent Solution here seems to me to be explicit type
 arguments.   Unless anyone else has better ideas.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5296#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

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

Reply via email to