Haddock 超链接并且没有关于冗余导入的警告
我的项目中有一个虚拟模块,其唯一目的是保存库其余部分的 Haddock 文档。事实上,我不需要导入此模块中的任何内容,但如果我不导入其他模块,Haddock 不会将函数名称超链接到其模块。
我的模块看起来像这样
{- |
Lots of Haddock text here... it references 'someFunction'.
-}
module TopLevelDoc () where
import Other.Module.With.SomeFunction
现在,如果我构建项目,我会收到此警告:
Warning: The import of `Other.Module.With.SomeFunction' is redundant
except perhaps to import instances from `Other.Module.With.SomeFunction'
To import instances alone, use: import Other.Module.With.SomeFunction()
如果我删除导入或将它们设为 ()
,Haddock 不会将 someFunction
超链接到其文档。如果我按原样保留此类导入,我会收到很多错误警告,这是我不喜欢的。我不想在整个项目中抑制这种警告,它可能对除了这个模块之外的任何其他模块都有用。
问题:
- 如何在构建时获得超链接的 Haddock 输出而不出现此类警告?
- 是否可以针对每个文件禁用警告? (就像我可以使用
.cabal
中的ghc-options
进行全局操作一样)
I have a dummy module in my project, whose sole purpose is to hold Haddock documentation for the rest of the library. In fact I don't need to import anything in this module, but if I don't import other modules, Haddock doesn't hyperlink function names to their modules.
My module looks like this
{- |
Lots of Haddock text here... it references 'someFunction'.
-}
module TopLevelDoc () where
import Other.Module.With.SomeFunction
Now if I build the project, I get this warning:
Warning: The import of `Other.Module.With.SomeFunction' is redundant
except perhaps to import instances from `Other.Module.With.SomeFunction'
To import instances alone, use: import Other.Module.With.SomeFunction()
If I remove imports or make them ()
, Haddock doesn't hyperlink someFunction
to its documentation. If I leave such imports as is, I get lots of false warnings, which I don't like. And I don't want to suppress this kind of warning for the entire project, it may be useful for any other module but this one.
Questions:
- How do I get hyperlinked Haddock output without such warnings when building?
- Is it possible to disable warnings on per-file basis? (like I can do it globally with
ghc-options
in.cabal
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要消除未使用的导入警告,您可以在文件顶部放置一个编译指示:
您可以通过显式限定它们来链接到不在范围内的标识符:
但是,这可能会使您的文档源代码相当难看,并且模块限定条件不会从输出中删除,因此我建议关闭警告。
To silence the unused import warning, you can put a pragma at the top of your file:
You can link to to identifiers that aren't in scope by explicitly qualifying them:
However, this will probably make your documentation source quite ugly, and the module qualifications aren't removed from the output, so I'd recommend turning off the warnings instead.