Created
August 29, 2014 08:15
-
-
Save voidlizard/c64b00b2926966ab3b97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :: MonadIO m => Int -> Source m BS.ByteString | |
source n = replicateM_ n $ do | |
n <- liftIO $ liftM (succ.(`mod` 15)) randomIO | |
s <- liftIO $ replicateM n (randomIO :: IO Word8) | |
yield (BS.pack s) | |
putter :: Putter BS.ByteString | |
putter s = do | |
putWord32le (fromIntegral (BS.length s)) | |
putByteString s | |
runMain :: FilePath -> Int -> IO () | |
runMain fn n = | |
runResourceT $ source n | |
$= conduitPut putter | |
$$ sinkFile fn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment