gpt4 book ai didi

haskell - 无法将预期类型 `Data.ByteString.Internal.ByteString' 与实际类型 `ByteString' 匹配

转载 作者:行者123 更新时间:2023-12-03 13:00:06 25 4
gpt4 key购买 nike

运行以下代码:

import Crypto.BCrypt
import Data.ByteString.Lazy.Char8

main = do
maybe_pwhash <- hashPasswordUsingPolicy slowerBcryptHashingPolicy (pack "hunter2")
print $ maybe_pwhash

我收到以下编译错误:

test.hs:5:70:
Couldn't match expected type `Data.ByteString.Internal.ByteString'
with actual type `ByteString'
In the return type of a call of `pack'
In the second argument of `hashPasswordUsingPolicy', namely
`(C.pack "hunter2")'
In a stmt of a 'do' block:
maybe_pwhash <- hashPasswordUsingPolicy
slowerBcryptHashingPolicy (pack "hunter2")

我很困惑,因为我不明白为什么 Data.ByteString.Internal.ByteString 之间有区别和 ByteString .

最佳答案

根据bcrypt docs ,你应该使用严格的字节串

import Data.ByteString.Char8

而不是懒惰的:
import Data.ByteString.Lazy.Char8

关于haskell - 无法将预期类型 `Data.ByteString.Internal.ByteString' 与实际类型 `ByteString' 匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20733924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com