小编Jan*_*Jan的帖子

为什么Data.Text.Lazy.replace和Data.Text.Lazy.append不起作用?

在下面的代码三种不同的方法(str1,str2,和str3使用替换字符串)Data.Text.Lazy.replace.他们应该提供相同的输出.

import Data.Text.Lazy as DTL

str1 :: String
str1 = DTL.unpack $ DTL.replace key value text
  where key = DTL.pack "<<name>>"
        value = DTL.pack "Joyce"
        text = DTL.pack "Hello, <<name>>."

str2 :: String
str2 = DTL.unpack $ DTL.replace key value text
  where key = DTL.pack "<<" `DTL.append` DTL.pack "name" 
                            `DTL.append` DTL.pack ">>"
        value = DTL.pack "Joyce"
        text = DTL.pack "Hello, <<name>>."

str3 :: String
str3 = DTL.unpack $ DTL.replace key value text …
Run Code Online (Sandbox Code Playgroud)

haskell

7
推荐指数
2
解决办法
231
查看次数

标签 统计

haskell ×1