Haskell 将字符串列表的列表转换为字符串

Haskell convert list of list of strings to string

我目前正在尝试将字符串列表的列表打印为单个字符串。我当前的代码是

pretty :: [[String]]->String
pretty x
   = concat(concat(x))

main :: IO ()
main
  = putStrLn (show (pretty [["hi","hi","hi"]]))

当被要求执行 pretty [["hi","hi","hi"]] 时,它会将其转换为“hihihi”,但是当被要求 pretty [["hi","hi","hi"]["hi","hi","hi"]] 时,编译器会给出以下错误

main.hs:7:29: error:
* Couldn't match expected type `[[Char]] -> [String]'
              with actual type `[[Char]]'
* The function `["hi", "hi", "hi"]' is applied to one argument,
  but its type `[[Char]]' has none
  In the expression: ["hi", "hi", "hi"] ["hi", "hi", "hi"]
  In the first argument of `pretty', namely
    `[["hi", "hi", "hi"] ["hi", "hi", ....]]'
 |
  7 |   = putStrLn (show (pretty [["hi","hi","hi"]["hi","hi","hi"]]))
 |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

没关系伙计们。原来我忘记了 [["hi","hi","hi"],["hi","hi","hi"]]

中的逗号