没有`mappend`连接两个Data.Text的标准方法 [英] Standard way of joining two Data.Texts without `mappend`
问题描述
我听说在未来的Haskell版本中, Data.Text
将会取代 String
s。我遇到的一个问题是仅为列表定义(++)
。要连接两个 Text
s,我需要使用
I hear that Data.Text
is going to replace String
s in future Haskell versions. One issue I have with this is that (++)
is defined for lists only. To concatenate two Text
s, I need to use
text1 `mappend` text2
快速获取详细信息。理想情况下,我希望能够在这些 Text
s上使用 ++
,但如果不是,另一个是什么替代?我可以定义自己的中缀运算符,但是我希望有一个标准的方法来完成这项工作。
Which gets verbose quickly. Ideally I'd like to be able to use ++
on these Text
s, but if not, what is another alternative? I could define my own infix operator, but I'd like a standard way of doing this.
推荐答案
从GHC 7.4确定哪一个版本)有一个与 mappend
相同的预定义的<>
运算符。所以你可以说:
From GHC 7.4 (not sure which point version) there is a predefined <>
operator that works the same as mappend
. So you'll be able to say
text1 <> text2
这就是标准中缀运算符,但它到处都没有。
So that's the "standard" infix operator, but it's not available everywhere yet.
这篇关于没有`mappend`连接两个Data.Text的标准方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!