make error slightly nicer

This commit is contained in:
rhiannon morris 2025-04-04 23:46:10 +02:00
parent 9e9788f88b
commit 6756c1f186

View file

@ -2,8 +2,9 @@ module Main (main) where
import IPS (Bytes, makeBytes) import IPS (Bytes, makeBytes)
import qualified IPS import qualified IPS
import System.Environment import System.Environment (getArgs)
import System.IO import System.Exit (exitFailure)
import System.IO (hPutBuf, withFile, IOMode(WriteMode))
import qualified Data.ByteString as ByteString import qualified Data.ByteString as ByteString
import qualified Data.Vector.Storable as Vector import qualified Data.Vector.Storable as Vector
@ -15,7 +16,9 @@ main = do
buf <- readBytes inf buf <- readBytes inf
ips <- either error id <$> IPS.parseFile ipsf ips <- either error id <$> IPS.parseFile ipsf
writeBytes outf $ IPS.apply ips buf writeBytes outf $ IPS.apply ips buf
_ -> error "usage: $0 <in> <ips> <out>" _ -> do
putStrLn "usage: ips <in> <ips> <out>"
exitFailure
readBytes :: FilePath -> IO Bytes readBytes :: FilePath -> IO Bytes
readBytes f = makeBytes <$> ByteString.readFile f readBytes f = makeBytes <$> ByteString.readFile f