[GHC] #7908: InstanceSigs suggestion not accepted

GHC cvs-ghc at haskell.org
Tue May 14 23:29:49 CEST 2013


#7908: InstanceSigs suggestion not accepted
---------------------------------+------------------------------------------
    Reporter:  heisenbug         |       Owner:                  
        Type:  bug               |      Status:  new             
    Priority:  normal            |   Milestone:                  
   Component:  Compiler          |     Version:  7.7             
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by simonpj):

 * cc: dimitris@…, dreixel (added)
  * difficulty:  => Unknown


Comment:

 This is a problem with the notation for kind polymorphism. This works:
 {{{
 instance Monad' (Hidden :: (k -> *) -> *) where
   return' :: forall (c :: k -> *) (a :: k) . c a -> Hidden c
   return' = Hide
   ...etc..
 }}}
 Note the kind signature on `Hidden`. That brings `k` into scope. Without
 that, `k` is not in scope.  And if it isn't in scope, GHC adds an implicit
 `forall` for the `k`.  So if you write
 {{{
 instance Monad Hidden where
   return' :: forall (c :: k -> *) (a :: k) . c a -> Hidden c
   return' = Hide
 }}}
 what you mean is:
 {{{
 instance Monad Hidden where
   return' :: forall k. forall (c :: k -> *) (a :: k) . c a -> Hidden c
   return' = Hide
 }}}
 And that is rightly rejected.

 So there are two problems:
  * The error message doesn't make it clear what exactly is wrong
  * Even if it did, the fix (bringing `k` into scope across the whole
 instance decl) is far from obvious

 Now that we understand the problem, any suggestions for what would be a
 better error message, or how to make the solution clearer?

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



More information about the ghc-tickets mailing list