Haskell中的单个实体如何重新出口
如何在Haskell中重新出口单个实体?
我知道可以重新出口模块,但是单个实体(例如函数)也可以吗?
我尝试了这个示例:
文件:yomedata.hs
module SomeData where
data SomeData = SomeData
文件: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’
单独的重新分组毫无问题,但是当我尝试尝试时要使用任何内容,我会得到错误:非法术语级别的使用构造函数'Someedata'。在这种情况下,Reexport.hs
到底是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
type构造函数,因此您可以使用
ymedata
作为类型:如果定义类型:
因此,您正在导出
worder stype
。如果您也想导出数据构造函数,则可以使用:
然后可以使用:
The type constructor, so you can use
SomeData
as type:If you defined a type:
you are thus exporting
SomeType
.If you want to export the data constructor as well, you use:
and then you can thus use: