如何导出数据族实例的构造函数?我已经尝试了各种方法但没有成功(请参阅注释掉的代码):
module Test (
--Foo () (..)
--type Foo () (..)
--UnitBar
) where
class Foo a where
data Bar a :: *
instance Foo () where
data Bar () = UnitBar
我能够成功导出构造函数的唯一方法是在执行
module Test where
请注意括号的空白。这种方法的缺点是留下的信息太多!
使用
module Test (
Bar(..)
) where
从关联的数据族Bar
导出所有构造函数。或
module Test (
Bar(UnitBar)
) where
仅导出单个构造函数。
您可以阅读GHC文档中的相关部分以获取更多详细信息。