這是我試圖在ghci中要做到:爲什麼Data.Text示例不適合我?
import Data.Text
strip " abc "
我收到此錯誤信息:
<interactive>:1:6:
Couldn't match expected type `Text' against inferred type `[Char]'
In the first argument of `strip', namely `" abc "'
In the expression: strip " abc "
In the definition of `it': it = strip " abc "
我期待這個工作,因爲它是在許多網頁包括這個答案給出:In Haskell, how do you trim whitespace from the beginning and end of a string?
我在做什麼錯?
重載字符串是最容易通過將編譯到您的名爲.hs文件的第一行來啓用:'{ - #語言OverloadedStrings# - }' – 2011-06-16 21:09:31