我有以下内容,我将使用pandoc将Markdown的抽象语法树的Plain节点转换为Link节点:
import Text.Pandoc
import Text.Pandoc.Walk (walk)
test :: Block -> Block
test (Plain xs) = Link xs "http://www.example.com/" ""
test x = x
readDoc :: String -> Pandoc
readDoc = readMarkdown def
writeDoc :: Pandoc -> String
writeDoc = writeMarkdown def
main :: IO ()
main = interact (writeDoc . walk test . readDoc)
Link等的定义是here。
当我编译时,我在第5行得到它,Couldn't match type ‘[Char]’ with ‘(String, String)’
我如何纠正我的符号? (我是Haskell的新手。)
答案 0 :(得分:3)
Link
的类型为[Inline] -> Target -> Inline
,其中Target
定义为type Target = (String, String)
。你的第二个参数应该是两个字符串的元组:
test :: Block -> Block
test (Plain xs) = Link xs ("http://www.example.com/", "")
test x = x