[GHC] #10270: inconsistent semantics of type class instance visibility outside recursive modules

GHC ghc-devs at haskell.org
Fri May 1 23:49:16 UTC 2015


#10270: inconsistent semantics of type class instance visibility outside recursive
modules
-------------------------------------+-------------------------------------
        Reporter:  skilpat           |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1
      Resolution:                    |                Keywords:
Operating System:  MacOS X           |            Architecture:  x86_64
 Type of failure:  GHC rejects       |  (amd64)
  valid program                      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:  #9562             |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by ezyang):

 Actually, the situation is a bit better here, because hs-boot operates
 strictly locally.  Here is a fix proposal:

 For non-orphan instances, we can't easily tell if an instance is supposed
 to be in scope unless we know whether or not the defining module is
 transitively reachable from the imports of a module. Fortunately, in
 `--make`, we do know this information from the import graph. So, for each
 module we compile, calculate a set of local hs/hs-boot modules which
 should be visible, and pass that along to the type-checker. Then, like for
 orphans, we only treat an instance as visible if it is in this set. (Note:
 we can't do this strategy for external instances, because we don't have
 the full dependency graph anymore.)

 I thought of this technique when I noticed that `--make` behavior was
 inconsistent, depending on whether or not a module was compiled before or
 after we retypecheck an hs-boot loop; if you always make sure modules
 which transitively have a `{-# SOURCE #-}` import on a booted module are
 type-checked BEFORE you typecheck the real implementation (even if there
 isn't a dependency), you will ensure that only the correct interfaces are
 in scope. But this is awfully delicate and wouldn't work well in the
 parallel make case, so just calculating the reachable set of nodes seems
 better.

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


More information about the ghc-tickets mailing list