*抱歉这个基本问题,刚开始学习 Haskell。
我正在尝试编写一个函数来获取一个字符串并返回一个加密的哈希值。
我现在想出的是:
encrypt :: ByteString -> ByteString
encrypt = do
x <- Crypto.Scrypt.encryptPassIO' (Pass "secret")
fmap Crypto.Scrypt.getEncryptedPass x
但是我得到了错误:
• Couldn't match expected type ‘ByteString’
with actual type ‘IO ByteString’
• In a stmt of a 'do' block: x <- encryptPassIO' (Pass plain)
In the expression:
do { x <- encryptPassIO' (Pass plain);
fmap Crypto.Scrypt.getEncryptedPass x }
In an equation for ‘encrypt’:
encrypt plain
= do { x <- encryptPassIO' (Pass plain);
fmap Crypto.Scrypt.getEncryptedPass x }
知道如何摆脱 IO 吗?
谢谢!