gpt4 book ai didi

haskell - 无法编译 Haskell 程序 ("Couldn' t 匹配“错误)

转载 作者:行者123 更新时间:2023-12-01 11:41:50 26 4
gpt4 key购买 nike

我正在尝试实现 John MacFarlane 的 Haskell 解决方案 here ,这应该允许我将带有 MathJax( latex )输入的 HTML 文件转换为 .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

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

ghc --make fixmath.hs

我收到以下错误:

[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

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

最佳答案

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

关于haskell - 无法编译 Haskell 程序 ("Couldn' t 匹配“错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19472828/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com