小编liu*_*tao的帖子

如何在Haskell中编写多行字符串?

假设我有这个带换行符的字符串文字:

file :: String
file = "the first line\nthe second line\nthe third line"
Run Code Online (Sandbox Code Playgroud)

有没有办法像这样写?

file :: String
file = "the first line
        the second line
        the third line"
Run Code Online (Sandbox Code Playgroud)

上面的尝试导致了这个错误:

factor.hs:58:33:
    lexical error in string/character literal at character '\n'
Failed, modules loaded: none.
Run Code Online (Sandbox Code Playgroud)

haskell

56
推荐指数
6
解决办法
2万
查看次数

标签 统计

haskell ×1