Replace String by Text

This commit is contained in:
Alexander Kobjolke 2023-08-13 13:32:14 +02:00
parent 81b0437bb7
commit 2ac76cb650
3 changed files with 8 additions and 3 deletions

View file

@ -1,6 +1,6 @@
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.34.4.
-- This file has been generated from package.yaml by hpack version 0.34.7.
--
-- see: https://github.com/sol/hpack
@ -25,6 +25,7 @@ library
ghc-options: -Wall -Wunused-packages
build-depends:
base >=4.13 && <5
, text
default-language: GHC2021
executable hcat
@ -37,4 +38,5 @@ executable hcat
build-depends:
base >=4.13 && <5
, hcat
, text
default-language: GHC2021

View file

@ -11,8 +11,8 @@ extra-source-files:
dependencies:
- base >= 4.13 && < 5
- text
# - bytestring
# - text
# - time
# - process
# - directory

View file

@ -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