[GHC] #8441: Allow family instances in an hs-boot file

#8441: Allow family instances in an hs-boot file ------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- Compiling an .hs-boot file with a data instance leads to this error: {{{ Illegal family instance in hs-boot file }}} Yet, data instances make good sense in an hs-boot file, in case another module wants to access a constructor declared in the instance. Furthermore, it may sometimes be desirable to allow type family instances in a hs-boot file, as well, in case some including modules need the instance for type simplification. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------ Reporter: goldfire | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by ezyang): There is an oblique comment from chak in 2a8cdc3aee5997374273e27365f92c161aca8453 about the issue here: {{{ -- Check for no family instances ; unless (null boot_fam_insts) $ panic ("TcRnDriver.checkHiBootIface: Cannot handle family " ++ "instances in boot files yet...") -- FIXME: Why? The actual comparison is not hard, but what would -- be the equivalent to the dfun bindings returned for class -- instances? We can't easily equate tycons... }}} In the case of type class instances, a boot interface may export a number of dictionary functions which the source file we're currently typechecking may have references to. The names of these dictionary functions are not canonical, so unlike normal exported identifiers, we can't simply take an identifier from the boot file and hope it will point to the right place. Instead, what hi-boot checking currently does is add a pile of dfun bindings to the source being typechecked, rewriting all of the booted dictionary functions to the appropriate places. In the case of type/data families, the comment seems to reason as follows: instead of dictionary functions, the boot interface exports a file of type functions. However, these need to be equated with the real versions in the hs file. And then the comment claims we cannot easily equate tycons. One thing to note is that while the rewriting is necessary for recursive modules, it's unnecessary if we're just interested in comparing two hi files. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------ Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by ezyang): * owner: => ezyang -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------ Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by ezyang): * keywords: => backpack -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------ Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 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): Let me know if I can be of assistance in this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------- Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: backpack, | TypeFamilies, hs-boot Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: backpack, TypeFamilies => backpack, TypeFamilies, hs-boot -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------- Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: backpack, | TypeFamilies, hs-boot Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): dcoutts points out a use case for type family instances in hsig files here: https://github.com/haskell/bytestring/issues/102 It should be easier to implement for hsig because we don't need to equate any coercions just check that the equality holds. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------- Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: backpack, | TypeFamilies, hs-boot Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ekmett): * cc: ekmett (added) Comment: Just had this bite me as well. I have a backpack signature in which I want to state requirements about several type instances being defined. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------- Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: backpack, | TypeFamilies, hs-boot Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by isovector): Was just bitten by this; annoyingly the associated type family instance in question is provided as a default by the typeclass. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------- Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: backpack, | TypeFamilies, hs-boot Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * priority: low => normal Comment: Bumping priority. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8441: Allow family instances in an hs-boot file -------------------------------------+------------------------------------- Reporter: goldfire | Owner: ezyang Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: backpack, | TypeFamilies, hs-boot Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): So, this is actually not so trivial even for Backpack. The problem is that data families turn into a rather delicate constellation of interface declarations, and the way signature merging is written, I have to teach it how to hoover these all up BACK into (deduplciated) FamInsts, so that when I write it out to an interface for the final time, everything is kosher. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8441#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC