嘿,如果有可能显示一个清单,我就会徘徊:
["one", "two", "three"]
Run Code Online (Sandbox Code Playgroud)
显示为
"one", "two", "three"
Run Code Online (Sandbox Code Playgroud)
需要它为文件完成
谢谢
你可以用intercalatefrom 来做到这一点Data.List
showList :: Show a => [a] -> String
showList = intercalate ", " . map show
Run Code Online (Sandbox Code Playgroud)
在map show每个元素用的引号的字符串表示(和任何内部引号正确转义)转换,而intercalate ", "碎片和胶水他们之间插入逗号和空格一起.