0
我在沙箱中工作與GHC 7.10.3,我有這個簡單的代碼:哈斯克爾:字節字符串的問題,當我使用getArgs
main :: IO()
main = do
args <- getArgs
case args of
[ newOauthConsumerKey, newOauthConsumerSecret ] -> do
let appOauth = newOAuth { oauthServerName = "api.twitter.com"
, oauthConsumerKey = newOauthConsumerKey
, oauthConsumerSecret = newOauthConsumerSecret
}
...
,當我在我的陰謀文件,這些依賴關係編譯:
base
, authenticate-oauth
, http-conduit
, aeson
, text
我一直在GET(清洗和重建的沙箱後)以下錯誤:
src/Test/Main.hs:60:55:
Couldn't match type ‘[Char]’
with ‘bytestring-0.10.6.0:Data.ByteString.Internal.ByteString’
Expected type: bytestring-0.10.6.0:Data.ByteString.Internal.ByteString
Actual type: String
In the ‘oauthConsumerKey’ field of a record
In the expression:
newOAuth
{oauthServerName = "api.twitter.com",
oauthConsumerKey = newOauthConsumerKey,
oauthConsumerSecret = newOauthConsumerSecret}
src/Test/Main.hs:61:55:
Couldn't match type ‘[Char]’
with ‘bytestring-0.10.6.0:Data.ByteString.Internal.ByteString’
Expected type: bytestring-0.10.6.0:Data.ByteString.Internal.ByteString
Actual type: String
In the ‘oauthConsumerSecret’ field of a record
In the expression:
newOAuth
{oauthServerName = "api.twitter.com",
oauthConsumerKey = newOauthConsumerKey,
oauthConsumerSecret = newOauthConsumerSecret}
我已經使用Google搜索並檢查了不同的類似答案,但我無法使其工作。任何想法?
解
的問題是由於這樣的事實,在代碼有用於import Data.Text
導入,其包括pack
,它不同於Data.ByteString.Char8
所需的pack
不同。一旦我包含它,它就起作用了。
我已經嘗試過它並沒有工作(忘了寫它的問題)。如果你在newOAuth中使用硬編碼的字符串,它將起作用。 – Randomize
np解決了,我編輯了我的問題 – Randomize