双美元符号 ($$) 在 Haskell 中表示什么?

What does a double-dollar sign ($$) mean in Haskell?

我正在尝试使用 LaTeX.hs as a guide. Extensive use of a $$ operator is made, but I can't find this in the Haskell syntax documentation 或什至在其他项目中引用 in 来为 pandoc 编写一个新的文件格式编写器。这是一个例子:

let align dir txt = inCmd "begin" dir $$ txt $$ inCmd "end" dir

这几乎看起来像是某种串联运算符,但我无法弄清楚它与其他串联运算符有何不同。这个运算符是什么,它是如何工作的,它在哪里记录?

这是 Hayoo or Hoogle. It's an operator defined in Text.Pandoc.Pretty 的工作。

($$) :: Doc -> Doc -> Doc infixr 5

a $$ b puts a above b.

基本上,它将确保 ab 在不同的行上,这会导致更好的 LaTeX 输出:

\begin{dir}
txt
\end{dir}

Pandoc 在内部定义了自己的漂亮打印库,但操作(和类型名称,Doc)在 Haskell 漂亮打印库中是标准的。 Pandoc 还定义了其他魔宠,如 vcathsep<+> 等;周围有很多漂亮的打印模块,但它们始终支持这些操作。

 > import Text.PrettyPrint
 > text "hello" <> text "world"
 helloworld
 > text "hello" <+> text "world"
 hello world
 > text "hello" $$ text "world" 
 hello
 world
 > text "hello" <+> text "world" $$ text "goodbye" <+> text "world"
 hello world
 goodbye world

ghci这里粗略的显示'what the document will look like'。