2013-09-30 31 views
3

如何导出我的数据族实例的构造函数?我已经试过各种方法都没有成功(见注释代码):导出数据族实例构造函数

module Test (
    --Foo() (..) 
    --type Foo() (..) 
    --UnitBar 
) where 

class Foo a where 
    data Bar a :: * 

instance Foo() where 
    data Bar() = UnitBar 

我已经能够successfuly出口的构造,唯一的方法做了

module Test where

注意括号的缺失。这种方法的缺点是太多的信息了!

+0

尝试'module Test(Bar(..))where' – viorior

回答

8

使用

module Test (
    Bar(..) 
) where 

所有构造函数从相关数据家人Bar出口。或者

module Test (
    Bar(UnitBar) 
) where 

只导出单个构造函数。

您可以阅读relevant section in GHC's documentation了解更多详情。