Skip to content

Instantly share code, notes, and snippets.

@voidlizard
Created August 29, 2014 08:15
Show Gist options
  • Save voidlizard/c64b00b2926966ab3b97 to your computer and use it in GitHub Desktop.
Save voidlizard/c64b00b2926966ab3b97 to your computer and use it in GitHub Desktop.
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