小编TSG*_*SGM的帖子

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

我试图落实约翰·麦克法兰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 …
Run Code Online (Sandbox Code Playgroud)

haskell haskell-platform pandoc

3
推荐指数
1
解决办法
655
查看次数

为什么这个if语句会给我一个错误

有人可以解释为什么这个简单的bash脚本:

#!/bin/bash

myvar="Hello"

if [[ -z "$myvar" ]]; then
    # echo "It's an unfilled string"
else
    echo "It's a filled string!"
fi
Run Code Online (Sandbox Code Playgroud)

给了我错误

./testscript: line 7: syntax error near unexpected token `else'
./testscript: line 7: `else'
Run Code Online (Sandbox Code Playgroud)

但是,如果我删除回声线上的注释,脚本运行正常.显然,在空if语句中注释行是一个问题.考虑到这一点,我该如何修复它以便我可以使用带有注释的空if语句?

bash shell

2
推荐指数
1
解决办法
79
查看次数

标签 统计

bash ×1

haskell ×1

haskell-platform ×1

pandoc ×1

shell ×1