Replace String by Text
This commit is contained in:
parent
81b0437bb7
commit
2ac76cb650
3 changed files with 8 additions and 3 deletions
|
|
@ -9,6 +9,9 @@ import System.IO (hPutStrLn, stderr)
|
|||
import Control.Exception qualified as Exception
|
||||
import System.IO.Error qualified as IOError
|
||||
|
||||
import Data.Text qualified as Text
|
||||
import Data.Text.IO qualified as TextIO
|
||||
|
||||
parseArgs :: [String] -> Either String FilePath
|
||||
parseArgs args = case args of
|
||||
[] -> Left "No filename given!"
|
||||
|
|
@ -19,7 +22,7 @@ runHCat :: IO ()
|
|||
runHCat = do
|
||||
fileNameOrError <- parseArgs <$> Env.getArgs
|
||||
fileName <- eitherToError fileNameOrError
|
||||
readFile fileName >>= putStr
|
||||
TextIO.readFile fileName >>= TextIO.putStr
|
||||
|
||||
eitherToError :: Show a => Either a b -> IO b
|
||||
eitherToError = either (Exception.throwIO . IOError.userError . show) return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue