指定空导出列表时有用吗?

Kap*_*pol 9 haskell module

通过仅指定一对括号作为导出列表,可以不导出模块的名称:

module MyModule () where
Run Code Online (Sandbox Code Playgroud)

在哪些情况下这会有用吗?据我所知,任何文件导入MyModule都无法使用内部声明的任何函数或类型MyModule.在这一点上似乎是语言的一个无用的功能,但我想这是有原因的.

lef*_*out 7

这样的模块仍将导出其中定义的任何类实例.

module A where

class Foo f where
  foo :: f

data Bar = Bar deriving (Show)
Run Code Online (Sandbox Code Playgroud)
module B () where

import A

instance Foo Bar where
  foo = Bar
Run Code Online (Sandbox Code Playgroud)
module C where

import A
import B -- won't compile without this import!

main = print (foo :: Bar)
Run Code Online (Sandbox Code Playgroud)