通过仅指定一对括号作为导出列表,可以不导出模块的名称:
module MyModule () where
在哪些情况下这会有用吗?据我所知,任何文件导入MyModule都无法使用内部声明的任何函数或类型MyModule.在这一点上似乎是语言的一个无用的功能,但我想这是有原因的.
这样的模块仍将导出其中定义的任何类实例.
module A where
class Foo f where
  foo :: f
data Bar = Bar deriving (Show)
module B () where
import A
instance Foo Bar where
  foo = Bar
module C where
import A
import B -- won't compile without this import!
main = print (foo :: Bar)