我正在學習haskell,並決定嘗試編寫一些小測試程序以使用Haskell代碼和使用模塊。目前我正嘗試使用第一個參數來使用Cypto.PasswordStore創建密碼哈希。爲了測試我的程序,我試圖從第一個參數創建一個散列,然後將散列打印到屏幕上。如何將一個Data.ByteString.Internal.ByteString放入?
import Crypto.PasswordStore
import System.Environment
main = do
args <- getArgs
putStrLn (makePassword (head args) 12)
,我發現了以下錯誤:
testmakePassword.hs:8:19:
Couldn't match expected type `String'
with actual type `IO Data.ByteString.Internal.ByteString'
In the return type of a call of `makePassword'
In the first argument of `putStrLn', namely
`(makePassword (head args) 12)'
In a stmt of a 'do' block: putStrLn (makePassword (head args) 12)
我使用以下鏈接作爲參考了,但我現在只是試示數無濟於事。 http://hackage.haskell.org/packages/archive/bytestring/0.9.0.4/doc/html/Data-ByteString-Internal.html http://hackage.haskell.org/packages/archive/pwstore-purehaskell/2.1/doc/html/Crypto-PasswordStore.html
謝謝!這對我有用。代碼會警告已棄用的函數,但答案就是我所需要的。 _Warning:使用'B.putStrLn' (從Data.ByteString導入): 棄用:「使用Data.ByteString.Char8.putStrLn而不是_ – NerdGGuy
@NerdGGuy讓我們擺脫'Data.ByteString', 。Data.ByteString.Char8'代替,然後(見編輯) – AndrewC
大使用Data.ByteString.Char8對我來說很有意義 – NerdGGuy