解释Haskell空导入列表()

dem*_*emi 7 haskell

我看到很多行import HSP.ServerPartT()- 导入列表是空的.为什么这样做?只是没有导入这个模块有什么区别?

ehi*_*ird 15

它仅从模块导入类型类实例.使用时-Wall,GHC会对导入的模块发出警告,但不会使用任何定义:

foo.hs:1:1:
    Warning: The import of `M' is redundant
               except perhaps to import instances from `M'
             To import instances alone, use: import M()
Run Code Online (Sandbox Code Playgroud)

空导入列表会使此警告静音,并作为导入目的的文档.