From 2ac76cb6500fd65a4c0551c0e17a3fa492174ad2 Mon Sep 17 00:00:00 2001 From: Alexander Kobjolke Date: Sun, 13 Aug 2023 13:32:14 +0200 Subject: [PATCH] Replace String by Text --- hcat.cabal | 4 +++- package.yaml | 2 +- src/HCat.hs | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hcat.cabal b/hcat.cabal index 3e69a9a..5c52af3 100644 --- a/hcat.cabal +++ b/hcat.cabal @@ -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 diff --git a/package.yaml b/package.yaml index 79cad12..fa4c58c 100644 --- a/package.yaml +++ b/package.yaml @@ -11,8 +11,8 @@ extra-source-files: dependencies: - base >= 4.13 && < 5 + - text # - bytestring -# - text # - time # - process # - directory diff --git a/src/HCat.hs b/src/HCat.hs index 6be48ae..6c44c9b 100644 --- a/src/HCat.hs +++ b/src/HCat.hs @@ -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