• simonpj's avatar
    [project @ 2001-12-06 10:45:42 by simonpj] · 61fae1d3
    simonpj authored
    --------------------------
    	Fix the instance-decl wart
    	--------------------------
    
    This commit implements the (proposed) H98 rule for
    resolving the class-method name in an instance decl.
    
    	module M( C( op1, op2 ) ) where
    		-- NB: op3 not exported
    	  class C a where
    	    op1, op2, op3 :: a -> a
    
    
    	module N where
    	  import qualified M as P( C )
    	  import qualified M as Q hiding( op2 )
    
    	  instance P.C Int where
    	    op1 x = x
    	    -- op2, op3 both illegal here
    
    The point is that
      a) only methods that can be named are legal
         in the instance decl
    	(so op2, op3 are not legal)
      b) but it doesn't matter *how* they can be named
    	(in this case Q.op1 is in scope, though
    	the class is called P.C)
    
    The AvailEnv carries the information about what's in scope,
    so we now have to carry it around in the monad, so that
    instance decl bindings can see it.  Quite simple really.
    
    Same deal for export lists. E.g.
    
    	module N( P.C( op1 ) ) where
    	  import qualified M as P( C )
    	  import qualified M as Q hiding( op2 )
    
    Actually this is what GHC has always implemented!
    61fae1d3
Rename.lhs 29.9 KB