无法编译Haskell程序("无法匹配"错误)

TSG*_*SGM 3 haskell haskell-platform pandoc

我试图落实约翰·麦克法兰Haskell的解决方案在这里,这应该让我的HTML文件转换与MathJax(乳胶)输入到.tex同时保留了数学.该脚本是:

import Text.Pandoc

main = toJsonFilter fixmath

fixmath :: Block -> Block
fixmath = bottomUp fixmathBlock . bottomUp fixmathInline

fixmathInline :: Inline -> Inline
fixmathInline (RawInline "html" ('<':'!':'-':'-':'M':'A':'T':'H':xs)) =
  RawInline "tex" $ take (length xs - 3) xs
fixmathInline x = x

fixmathBlock :: Block -> Block
fixmathBlock (RawBlock "html" ('<':'!':'-':'-':'M':'A':'T':'H':xs)) =
  RawBlock "tex" $ take (length xs - 3) xs
fixmathBlock x = x
Run Code Online (Sandbox Code Playgroud)

我安装了64位OSX版本的Haskell,并且还给出了cabal install pandoc获取pandoc函数的命令.但是,在执行时

ghc --make fixmath.hs
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

[1 of 1] Compiling Main             ( fixmath.hs, fixmath.o )

fixmath.hs:9:26:
    Couldn't match expected type `Format' with actual type `[Char]'
    In the pattern: "html"
    In the pattern:
      RawInline "html"
                ('<' : '!' : '-' : '-' : 'M' : 'A' : 'T' : 'H' : xs)
    In an equation for `fixmathInline':
        fixmathInline
          (RawInline "html"
                     ('<' : '!' : '-' : '-' : 'M' : 'A' : 'T' : 'H' : xs))
          = RawInline "tex" $ take (length xs - 3) xs

fixmath.hs:10:13:
    Couldn't match expected type `Format' with actual type `[Char]'
    In the first argument of `RawInline', namely `"tex"'
    In the expression: RawInline "tex"
    In the expression: RawInline "tex" $ take (length xs - 3) xs

fixmath.hs:14:24:
    Couldn't match expected type `Format' with actual type `[Char]'
    In the pattern: "html"
    In the pattern:
      RawBlock "html"
               ('<' : '!' : '-' : '-' : 'M' : 'A' : 'T' : 'H' : xs)
    In an equation for `fixmathBlock':
        fixmathBlock
          (RawBlock "html"
                    ('<' : '!' : '-' : '-' : 'M' : 'A' : 'T' : 'H' : xs))
          = RawBlock "tex" $ take (length xs - 3) xs

fixmath.hs:15:12:
    Couldn't match expected type `Format' with actual type `[Char]'
    In the first argument of `RawBlock', namely `"tex"'
    In the expression: RawBlock "tex"
    In the expression: RawBlock "tex" $ take (length xs - 3) xs
Run Code Online (Sandbox Code Playgroud)

出了什么问题,我该怎么办?

Joh*_*ane 5

最新版本的pandoc改变了RawBlock和RawInline的"格式"类型.如果更换"html""tex"(Format "html")(Format "tex"),你应该没问题.(假设除了编译器标记的问题之外没有其他问题.)