开始Haskell - 获取无法匹配类型'[Char]'与'(String,String)'

时间:2014-12-14 02:13:53

标签: haskell pandoc

我有以下内容,我将使用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的新手。)

1 个答案:

答案 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