[GHC] #1480: Template Haskell should allow reification of modules

GHC ghc-devs at haskell.org
Mon Nov 4 13:58:53 UTC 2013


#1480: Template Haskell should allow reification of modules
----------------------------+----------------------------------------------
        Reporter:  igloo    |            Owner:
            Type:  feature  |           Status:  closed
  request                   |        Milestone:  7.8.1
        Priority:  highest  |          Version:  7.7
       Component:           |         Keywords:
  Template Haskell          |     Architecture:  Unknown/Multiple
      Resolution:  fixed    |       Difficulty:  Moderate (less than a day)
Operating System:           |       Blocked By:
  Unknown/Multiple          |  Related Tickets:
 Type of failure:           |
  None/Unknown              |
       Test Case:           |
        Blocking:  8398     |
----------------------------+----------------------------------------------

Comment (by errge):

 I have to experiment a bit more around this, but at a first glance, I see
 this in ```HscTypes.lhs```:
 {{{

 -- | Records modules that we depend on by making a direct import from
 data Usage
   -- | Module from another package
   = UsagePackageModule {
         usg_mod      :: Module,
            -- ^ External package module depended on
         usg_mod_hash :: Fingerprint,
             -- ^ Cached module fingerprint
         usg_safe :: IsSafeImport
             -- ^ Was this module imported as a safe import
     }
   -- | Module from the current package
   | UsageHomeModule {
         usg_mod_name :: ModuleName,
             -- ^ Name of the module
         usg_mod_hash :: Fingerprint,
             -- ^ Cached module fingerprint
         usg_entities :: [(OccName,Fingerprint)],
             -- ^ Entities we depend on, sorted by occurrence name and
 fingerprinted.
             -- NB: usages are for parent names only, e.g. type
 constructors
             -- but not the associated data constructors.
         usg_exports  :: Maybe Fingerprint,
             -- ^ Fingerprint for the export list we used to depend on this
 module,
             -- if we depend on the export list
         usg_safe :: IsSafeImport
             -- ^ Was this module imported as a safe import
     }                                           -- ^ Module from the
 current package
   -- | A file upon which the module depends, e.g. a CPP #include, or using
 TH's
   -- 'addDependentFile'
   | UsageFile {
         usg_file_path  :: FilePath,
         -- ^ External file dependency. From a CPP #include or TH
         -- addDependentFile. Should be absolute.
         usg_file_hash  :: Fingerprint
         -- ^ 'Fingerprint' of the file contents.

         -- Note: We don't consider things like modification timestamps
         -- here, because there's no reason to recompile if the actual
         -- contents don't change.  This previously lead to odd
         -- recompilation behaviors; see #8114
   }
     deriving( Eq )
         -- The export list field is (Just v) if we depend on the export
 list:
         --      i.e. we imported the module directly, whether or not we
         --           enumerated the things we imported, or just imported
         --           everything
         -- We need to recompile if M's exports change, because
         -- if the import was    import M,       we might now have a name
 clash
         --                                      in the importing module.
         -- if the import was    import M(x)     M might no longer export x
         -- The only way we don't depend on the export list is if we have
         --                      import M()
         -- And of course, for modules that aren't imported directly we
 don't
         -- depend on their export lists
 }}}

 As you can see, UsagePackageModule doesn't have a usg_exports field, only
 UsageHomeModule.  So I can't decide about directness of the import based
 on usg_exports alone.

 Maybe we should make this info more explicit in Usages if we want to
 depend on it for TH reification.

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


More information about the ghc-tickets mailing list