.cabal 中的 {} 用于 Haskell 中的 Haddock 文档
收到该行
> { -# OPTIONS_GHC -fglasgow-exts -XTemplateHaskell #- }
如果我在 .cabal 文件的文档部分(描述)中
haddock: parsing haddock prologue failed
,则在运行时
$ cabal haddock
我会收到错误消息,但如果我去掉 {
和 }一切正常。是否有某种方法可以转义
{}
以便可以在说明中使用它们?
If I got the line
> { -# OPTIONS_GHC -fglasgow-exts -XTemplateHaskell #- }
in the documentation-part (description) of the .cabal-file I'll get the error message
haddock: parsing haddock prologue failed
when running
$ cabal haddock
but if I get rid of the {
and }
everything works fine. Is there some way to escape {}
so they can be used in the description?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Haddock 有两种代码块语法——用
@
分隔块的语法允许您使用 HTML 转义符,它可用于嵌入 Cabal 解析器无法处理的字符。不幸的是,Cabal 似乎从
@
分隔的块中去除了前导空格,因此您还必须在任何带有空格的行前面加上 HTML 编码的空格。
这是一个示例:
它呈现为:
Haddock has two syntaxes for code blocks -- the syntax that delimits blocks with
@
allows you to use HTML escapes, which can be used to embed characters that Cabal's parser can't deal with.Unfortunately, it seems that Cabal strips the leading whitespace from
@
-delimited blocks, so you also have to prefix any lines with spaces with an HTML-encoded space.
Here's am example:
Which renders to:
OPTIONS_GHC
本身并未被弃用(例如,您可以利用它来启用特定的构建选项),但使用它来打开/关闭语言功能并不被认为是好的做法。请改用{-# LANGUAGE ... #-}
编译指示。例如
{-# LANGUAGE TemplateHaskell,foreignFunctionInterface, RankNTypes #-}
另外,使用包罗万象的
-fglasgow-exts
被认为是不好的形式。最好只包含您需要的扩展,这样对于任何刚接触您的代码的人来说都更清楚需要哪些扩展。OPTIONS_GHC
itself is not deprecated (you'd utilize this to enable particular build options, for example), but using it to turn on/off language features is not considered good practice . Use{-# LANGUAGE ... #-}
pragmas instead.e.g.
{-# LANGUAGE TemplateHaskell, ForeignFunctionInterface, RankNTypes #-}
Also, it's considered bad form to utilize the all-encompassing
-fglasgow-exts
. Better to just include the extensions you need, and that way it's clearer which are required for anyone new to your code.