Replace String by Text
This commit is contained in:
parent
81b0437bb7
commit
2ac76cb650
3 changed files with 8 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
cabal-version: 1.12
|
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
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
|
|
@ -25,6 +25,7 @@ library
|
||||||
ghc-options: -Wall -Wunused-packages
|
ghc-options: -Wall -Wunused-packages
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.13 && <5
|
base >=4.13 && <5
|
||||||
|
, text
|
||||||
default-language: GHC2021
|
default-language: GHC2021
|
||||||
|
|
||||||
executable hcat
|
executable hcat
|
||||||
|
|
@ -37,4 +38,5 @@ executable hcat
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.13 && <5
|
base >=4.13 && <5
|
||||||
, hcat
|
, hcat
|
||||||
|
, text
|
||||||
default-language: GHC2021
|
default-language: GHC2021
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ extra-source-files:
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- base >= 4.13 && < 5
|
- base >= 4.13 && < 5
|
||||||
|
- text
|
||||||
# - bytestring
|
# - bytestring
|
||||||
# - text
|
|
||||||
# - time
|
# - time
|
||||||
# - process
|
# - process
|
||||||
# - directory
|
# - directory
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ import System.IO (hPutStrLn, stderr)
|
||||||
import Control.Exception qualified as Exception
|
import Control.Exception qualified as Exception
|
||||||
import System.IO.Error qualified as IOError
|
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 :: [String] -> Either String FilePath
|
||||||
parseArgs args = case args of
|
parseArgs args = case args of
|
||||||
[] -> Left "No filename given!"
|
[] -> Left "No filename given!"
|
||||||
|
|
@ -19,7 +22,7 @@ runHCat :: IO ()
|
||||||
runHCat = do
|
runHCat = do
|
||||||
fileNameOrError <- parseArgs <$> Env.getArgs
|
fileNameOrError <- parseArgs <$> Env.getArgs
|
||||||
fileName <- eitherToError fileNameOrError
|
fileName <- eitherToError fileNameOrError
|
||||||
readFile fileName >>= putStr
|
TextIO.readFile fileName >>= TextIO.putStr
|
||||||
|
|
||||||
eitherToError :: Show a => Either a b -> IO b
|
eitherToError :: Show a => Either a b -> IO b
|
||||||
eitherToError = either (Exception.throwIO . IOError.userError . show) return
|
eitherToError = either (Exception.throwIO . IOError.userError . show) return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue