[GHC] #9780: dep_orphs in Dependencies redundantly records type family orphans

#9780: dep_orphs in Dependencies redundantly records type family orphans
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure: Compile-
Blocked By: | time performance bug
Related Tickets: | Test Case:
| Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Currently, there is a comment on `dep_orphs` claiming this:
{{{
, dep_orphs :: [Module]
-- ^ Orphan modules (whether home or external
pkg),
-- *not* including family instance orphans as they
-- are anyway included in 'dep_finsts'
}}}
However, it is not difficult to discover that this is not true:
{{{
[ezyang@hs01 ghc-quick]$ cat A.hs
{-# LANGUAGE TypeFamilies #-}
module A where
type family F a :: *
[ezyang@hs01 ghc-quick]$ cat B.hs
{-# LANGUAGE TypeFamilies #-}
module B where
import A
type instance F Int = Bool
[ezyang@hs01 ghc-quick]$ cat C.hs
module C where
import B
[ezyang@hs01 ghc-quick]$ inplace/bin/ghc-stage2 --show-iface C.hi | grep
orphans
orphans: GHC.Base GHC.Float B
}}}
I'm not sure if the comment or the implementation is wrong. Certainly
`TcRnDriver` would not work if we removed type family orphans from the
list, because we only currently load `imp_orphans` and not `imp_finsts`.
This change occured in this commit:
{{{
commit 8f212ab5307434edf92c7d10fe0df88ccb5cd6ca
Author: Simon Peyton Jones

#9780: dep_orphs in Dependencies redundantly records type family orphans
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: bug | Status: closed
Priority: normal | Milestone: 7.10.1
Component: Compiler | Version: 7.9
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by thomie):
* status: new => closed
* resolution: => fixed
* milestone: => 7.10.1
Comment:
You updated that comment in commit
4c834fdddf4d44d12039da4d6a2c63a660975b95:
{{{
Author: Edward Z. Yang <>
Date: Mon Nov 17 21:23:52 2014 -0800
Filter instance visibility based on set of visible orphans, fixes
#2182.
Summary:
Amazingly, the fix for this very old bug is quite simple: when type-
checking,
maintain a set of "visible orphan modules" based on the orphans list
of
modules which we explicitly imported. When we import an instance and
it
is an orphan, we check if it is in the visible modules set, and if
not,
ignore it. A little bit of refactoring for when orphan-hood is
calculated
happens so that we always know if an instance is an orphan or not.
For GHCi, we preinitialize the visible modules set based on the list
of
interactive imports which are active.
Future work: Cache the visible orphan modules set for GHCi, rather
than
recomputing it every type-checking round. (But it's tricky what to do
when you
/remove/ a module: you need a data structure a little more complicated
than
just a set of modules.)
Signed-off-by: Edward Z. Yang

#9780: dep_orphs in Dependencies redundantly records type family orphans -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * status: closed => new * resolution: fixed => Comment: I now realize this bug report is not just about changing the invalid comment, but also about performing the optimization mentioned in the title. In `main/HscTypes.hs`: {{{ , dep_orphs :: [Module] -- ^ Transitive closure of orphan modules (whether -- home or external pkg). -- -- (Possible optimization: don't include family -- instance orphans as they are anyway included in -- 'dep_finsts'. But then be careful about code -- which relies on dep_orphs having the complete list!) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9780#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9780: dep_orphs in Dependencies redundantly records type family orphans -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by hvr): * milestone: 7.10.1 => 7.12.1 Comment: I guess this is 7.12 material now... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9780#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC