我正在使用 ghc 7.10.3 的沙箱中工作,并且我有这个简单的代码:
main :: IO ()
main = do
args <- getArgs
case args of
[ newOauthConsumerKey, newOauthConsumerSecret ] -> do
let appOauth = newOAuth { oauthServerName = "api.twitter.com"
, oauthConsumerKey = newOauthConsumerKey
, oauthConsumerSecret = newOauthConsumerSecret
}
...
当我在我的 cabal 文件中使用这些依赖项编译它时:
base
, authenticate-oauth
, http-conduit
, aeson
, text
我继续得到(在清理和重建沙箱之后)以下错误:
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}
我已经用谷歌搜索并检查了不同的类似答案,但我无法让它发挥作用。任何想法?
解决方案
问题是由于在代码中有一个import Data.Text
包含 a的导入,pack
这与pack
. Data.ByteString.Char8
一旦我包含它,它就起作用了。