[GHC] #9256: Support automatic derivation of an hs-boot file from an hs file

GHC ghc-devs at haskell.org
Thu Jul 3 10:57:36 UTC 2014


#9256: Support automatic derivation of an hs-boot file from an hs file
-------------------------------------+------------------------------------
        Reporter:  ezyang            |            Owner:  ezyang
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.8.2
      Resolution:                    |         Keywords:  backpack
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by ezyang):

 Bikeshedding syntax a little bit, here are two alternate way A.hs could be
 written:

 Inline annotations:

 {{{
 module A where

 import B

 data Arf = MkArf (Maybe Bar) {-# BOOT_ABSTRACT #-}
 }}}

 Exclusionary (but as mentioned before, this syntax is a little
 problematic):

 {{{
 module A where

 {-# BOOT_EXCLUDE Arf(..) #-}

 import B

 data Arf = MkArf (Maybe Bar)
 }}}

 Now to answer your questions:

 > An hs-boot file tends to have a mix of `{-# SOURCE #-}` imports and
 regular imports. The list of imports in the hs-boot file will be different
 than the list in the master file, and where the `{-# SOURCE #-}` pragma
 appears will be different. (There's a subset relationship between the
 import lists, of course.) How will this new syntax figure out which
 imports are necessary to type check the `BOOT_TYPES`?

 I imagine we'll have to augment the syntax to get all of the necessary
 information: I don't think it would be right to automatically compute it.
 However, I think the most common case is that of a simple mutual recursive
 group of two modules, in which case no changes to the imports are
 necessary. So I don't mind if the syntax just says directly, "This is a
 concrete import in the hs version, but a source import in the hs-boot
 version." (In Backpack-land, this case is probably common enough that it
 merits a shortcut.

 > It is sometimes desirable to include type definitions in hi-boot files.
 How does this syntax accommodate that need?

 I am not really sure what you mean by type definitions here, but surely
 they must still be defined in some way in the source file? Then we can
 annotate it to say that it should be included in the boot. Ditto with type
 synonyms and type families.

 I agree, there's a lot of syntax to be bikeshed here.

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


More information about the ghc-tickets mailing list