Data.ByteString(その2)
as構文を使って、import宣言を書き直してみました。
{- Usage: splitfile path -} module Main (main) where import System (getArgs) import Data.ByteString (ByteString, empty) import qualified Data.ByteString as BS main :: IO () main = do args <- getArgs splitFile (head args) blockSize = 100 splitFile :: FilePath -> IO () splitFile path = do content <- BS.readFile path putFiles $ zip (map (makeFileName) [1, 2 ..]) (split blockSize content) where makeFileName :: Int -> String makeFileName n = path ++ "." ++ (show n) split :: Int -> ByteString -> [ByteString] split n bytes | bytes == empty = [] | otherwise = let (f, rest) = BS.splitAt n bytes in (f : split n rest) putFiles :: [(FilePath, ByteString)] -> IO () putFiles [] = return () putFiles ((path, content):xs) = do BS.writeFile path content putFiles xs