[GHC] #10027: Importing constructor of associated data type fails
GHC
ghc-devs at haskell.org
Mon Jan 26 20:45:50 UTC 2015
#10027: Importing constructor of associated data type fails
-------------------------------------+-------------------------------------
Reporter: lspitzner | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.4
Keywords: | Operating System: Unknown/Multiple
constructor import associated | Type of failure: None/Unknown
data type | Blocked By:
Architecture: | Related Tickets:
Unknown/Multiple |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
I will base my description on the code you find when searching for
"instance PersistEntity" on http://www.yesodweb.com/book/persistent. In
summary, the code looks like
{{{#!hs
instance PersistEntity Person where
...
data EntityField Person typ where
PersonId :: EntityField Person PersonId
PersonName :: EntityField Person String
PersonAge :: EntityField Person Int
...
}}}
This code is generated from TH (see above). I have not tested if it
matters that it is generated. A first step could be to test if manually
replacing the TH part yields different results.
The problem is: When i add this code in one module, do ''not'' create an
export list for that module, and try to import the constructors explicitly
(i.e. with a list) in a different module, it does not work.
I read and tried to follow the description on
https://wiki.haskell.org/GHC/Type_families, chapter 4.3.
== Testcase 1 ==
(not really expected to work; still intersting error message)
{{{#!hs
import MyModuleContainingInstancePerson ( PersonId )
}}}
ghc says
{{{
‘PersonId’ is a data constructor of ‘EntityField’
To import it use
‘import’ MyModuleContainingInstancePerson( EntityField(
VersionVersion ) )
or
‘import’ MyModuleContainingInstancePerson( EntityField(..) )
}}}
== Testcase 2 ==
(no export list in {{{MyModuleContainingInstancePerson}}})
{{{#!hs
import MyModuleContainingInstancePerson ( EntityField(..) )
}}}
ghc says
{{{
Module ‘MyModuleContainingInstancePerson’ does not export
‘EntityField(..)’
}}}
== Testcase 3 ==
But ''when i do provide'' an export list in
{{{MyModuleContainingInstancePerson}}}, like
{{{#!hs
module MyModuleContainingInstancePerson ( Person(..), EntityField(..) )
where ..
}}}
Testcase 2 suddenly works.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10027>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list