Issue
How to re-export a single entity in haskell?
I know modules can be re-exported, but is this also possible for a single entity (like a function)?
I've tried this example:
File: SomeData.hs
module SomeData where
data SomeData = SomeData
File: ReExport.hs
module ReExport ( SomeData ) where
import SomeData
File: Main.hs
import ReExport
x = SomeData -- Error on this line: Illegal term-level use of the type constructor ‘SomeData’
The re-export alone compiles with no problems, but when I try to use anything from it I get the error: Illegal term-level use of the type constructor ‘SomeData’. What exactly is ReExport.hs exporting in this case?
Solution
What exactly is ReExport.hs exporting in this case?
The type constructor, so you can use SomeData as type:
import ReExport
x :: SomeData
x = undefinedIf you defined a type:
data SomeType = SomeDatayou are thus exporting SomeType.
If you want to export the data constructor as well, you use:
module ReExport (SomeData(SomeData)) where
import SomeDataand then you can thus use:
import ReExport
x :: SomeData
x = SomeDataAnswered By - Willem Van Onsem Answer Checked By - Marie Seifert (PHPFixing Admin)
 
 Posts
Posts
 
 
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.