module Main (main) where import IPS (Bytes, makeBytes) import qualified IPS import System.Environment import System.IO import qualified Data.ByteString as ByteString import qualified Data.Vector.Storable as Vector main :: IO () main = do args <- getArgs case args of [inf, ipsf, outf] -> do buf <- readBytes inf ips <- either error id <$> IPS.read ipsf writeBytes outf $ IPS.apply ips buf _ -> error "usage: $0 " readBytes :: FilePath -> IO Bytes readBytes f = makeBytes <$> ByteString.readFile f writeBytes :: FilePath -> Bytes -> IO () writeBytes f buf = withFile f WriteMode \h -> Vector.unsafeWith buf \ptr -> hPutBuf h ptr (Vector.length buf)