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

GHC ghc-devs at haskell.org
Tue Jul 1 19:51:52 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 goldfire):

 Thanks. Let me try to spit back what you're saying:

 {{{
 module A where

 import B

 data Arf = MkArf (Maybe Bar)
 }}}

 {{{
 module B where

 import A

 data Bar = MkBar (Maybe Arf)
 }}}

 The above modules will currently fail to compile because of the import
 cycle. The current solution is to write an ''A.hs-boot'' file declaring
 `data Arf` and putting a `{-# SOURCE #-}` pragma in `B`.

 Your proposed solution is like this:
 {{{
 module A where

 {-# BOOT_TYPES Arf #-}

 import B

 data Arf = MkArf (Maybe Bar)
 }}}

 {{{
 module B where

 import {-# SOURCE #-} A

 data Bar = MkBar (Maybe Arf)
 }}}

 Is this correct? I like the idea in general, but there are some pitfalls I
 see:

 * 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`?

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

 * Similarly, one may want type synonyms and type families available in hi-
 boot files. How do these work?

 Thanks!

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


More information about the ghc-tickets mailing list