[GHC] #9204: Conflicting definition in hs-boot file

#9204: Conflicting definition in hs-boot file ------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- Foo.hs: {{{ module Foo where import Bar data Foo a }}} Foo.hs-boot: {{{ module Foo where data Foo a }}} Bar.hs: {{{ module Bar where import {-# SOURCE #-} Foo }}} With GHC 7.8.2 I'm getting the error {{{ Foo.hs-boot:3:1: Type constructor ‘Foo’ has conflicting definitions in the module and its hs-boot file Main module: type role Foo phantom data Foo a Boot file: data Foo a }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------ Reporter: Feuerbach | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 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 Feuerbach): If I add a role annotation to the hs-boot file, this works. My guess is that since the hs-boot doesn't have the complete information about the type, it cannot infer the phantom role of the parameter. Still, I wish I didn't have to deal with this. But if this isn't possible, at least the error message should suggest adding the role annotation to the hs-boot file. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------ Reporter: Feuerbach | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Documentation | Version: 7.8.2 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 goldfire): * owner: => goldfire * component: Compiler => Documentation Comment: Replying to [comment:1 Feuerbach]:
If I add a role annotation to the hs-boot file, this works
My guess is that since the hs-boot doesn't have the information about
Still, I wish I didn't have to deal with this. But if this isn't
Yes, that's the solution. . the data constructors, it cannot infer the phantom role of the parameter. Yes. As documented [http://www.haskell.org/ghc/docs/latest/html/users_guide/separate- compilation.html#mutual-recursion here], in the last bullet point before 4.7.10, role inference in hs-boot files defaults to representational, the most common case. possible, at least the error message should suggest adding the role annotation to the hs-boot file. Yes, absolutely. I will fix in due course, and clarify some of this in the manual as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: goldfire Type: bug | Status: patch Priority: normal | Milestone: Component: | Version: 7.8.2 Documentation | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: Phab:D458 | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => patch * differential: => Phab:D458 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file
-------------------------------------+-------------------------------------
Reporter: Feuerbach | Owner: goldfire
Type: bug | Status: patch
Priority: normal | Milestone:
Component: | Version: 7.8.2
Documentation | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: Phab:D458 |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9204: Conflicting definition in hs-boot file
-------------------------------------+-------------------------------------
Reporter: Feuerbach | Owner: goldfire
Type: bug | Status: patch
Priority: normal | Milestone:
Component: | Version: 7.8.2
Documentation | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: Phab:D458 |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9204: Conflicting definition in hs-boot file
-------------------------------------+-------------------------------------
Reporter: Feuerbach | Owner: goldfire
Type: bug | Status: patch
Priority: normal | Milestone:
Component: | Version: 7.8.2
Documentation | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: Phab:D458 |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: Component: | Version: 7.8.2 Documentation | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | roles/should_fail/T9204 | Blocking: | Differential Revisions: Phab:D458 | -------------------------------------+------------------------------------- Changes (by goldfire): * status: patch => closed * testcase: => roles/should_fail/T9204 * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: Component: Documentation | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | roles/should_fail/T9204 | Blocking: | Differential Revisions: Phab:D458 -------------------------------------+------------------------------------- Comment (by phischu): In the following example the complete data declaration happens to be present in the hs-boot file: Foo.hs: {{{ module Foo where import Bar data P a = P }}} Foo.hs-boot: {{{ module Foo where data P a = P }}} Bar.hs: {{{ module Bar where import {-# SOURCE #-} Foo }}} Could you now do role inference in the hs-boot file as well, so that the example compiles? My use-case is that I generate hs-boot files by copying whole declarations. Thank you. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: Type: bug | Status: new Priority: low | Milestone: 7.12.1 Component: Documentation | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | roles/should_fail/T9204 | Blocking: | Differential Revisions: Phab:D458 -------------------------------------+------------------------------------- Changes (by goldfire): * owner: goldfire => * priority: normal => low * status: closed => new * resolution: fixed => * milestone: => 7.12.1 Comment: Yes, the suggestion in comment:8 is reasonable: Use `phantom` as the default role in hs-boot files when the definition is supplied. Even today, GHC does do role inference in hs-boot files -- it just uses a different default. But there is no reason to change the default if a definition is supplied. Thanks for the suggestion. However, because this is a user-facing change, it's not appropriate (in my opinion) to make the change for 7.10. And, it's just barely possible that this will break code. The following compiles today: A.hs-boot: {{{ module A where data P a = P }}} A.hs: {{{ module A where type role P representational data P a = P }}} Under the proposed change, this example would fail due to the missing role annotation in the hs-boot file. That said, I'm still in favor of the change, just documenting what would break. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: goldfire Type: bug | Status: new Priority: low | Milestone: 7.12.1 Component: Documentation | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | roles/should_fail/T9204 | Blocking: | Differential Revisions: Phab:D458 -------------------------------------+------------------------------------- Changes (by goldfire): * owner: => goldfire -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: goldfire Type: bug | Status: new Priority: low | Milestone: 7.12.1 Component: Documentation | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | roles/should_fail/T9204 | Blocking: | Differential Revisions: Phab:D458 -------------------------------------+------------------------------------- Comment (by simonpj): OK let's change this for 7.12, and document the change. Richard, you took ownership, so maybe do this whenever it's convenient to you. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9204: Conflicting definition in hs-boot file
-------------------------------------+-------------------------------------
Reporter: Feuerbach | Owner: goldfire
Type: bug | Status: new
Priority: low | Milestone: 7.12.1
Component: Documentation | Version: 7.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | roles/should_fail/T9204
| Blocking:
| Differential Revisions: Phab:D458
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9204: Conflicting definition in hs-boot file -------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: goldfire Type: bug | Status: closed Priority: low | Milestone: 7.12.1 Component: Documentation | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | roles/should_fail/T9204 | roles/should_compile/T9204b | Blocking: | Differential Revisions: Phab:D458 -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * testcase: roles/should_fail/T9204 => roles/should_fail/T9204 roles/should_compile/T9204b * resolution: => fixed Comment: This is a user-facing change, so wait until 7.12. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9204#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC