I am trying to create a random lazy ByteString the same length as the lazy ByteString that I already have.
So, I take the length of the ByteString and pass it to getEntropy as follows:
import qualified Data.ByteString.Lazy.Char8 as L import qualified System.Entropy as SE string :: L.ByteString string = L.pack "Hello world!" randomString :: IO L.ByteString randomString = L.fromChunks . (:[]) <$> SE.getEntropy (L.length string)
(using L.fromChunks . (:[]) to convert from strict ByteString to lazy.)
The problem is that SE.getEntropy is of type Int -> IO ByteString , and L.length is of type L.ByteString -> GHC.Int.Int64 .
How to convert Int64 to Int ?
source share