packages feed

path-text-utf8 0.0.1.10 → 0.0.1.11

raw patch · 4 files changed

+97/−60 lines, 4 filesdep ~basedep ~bytestringdep ~pathPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, bytestring, path, text

API changes (from Hackage documentation)

Files

+ changelog.md view
@@ -0,0 +1,47 @@+### 0.0.1.11 (2023-01-11)++Support GHC 9.4++### 0.0.1.10 (2022-03-15)++* Shift supported GHC range to 8.10, 9.0, 9.2+* Shift supported `path` versions to 0.8, 0.9+* Raise `safe-exceptions` lower bound to 0.1.7++### 0.0.1.8 (2021-06-03)++- Raise `base` lower bound to 4.10+- Raise `bytestring` lower bound to 0.10.6+- Raise `safe-exceptions` lower bound to 0.1.5.0+- Raise `text` lower bound to 1.2.2+- Support `base` 4.15 (support GHC 9.0)+- Support `bytestring` 0.11+- Support `path` 0.8++### 0.0.1.6 (2020-05-20)++Support GHC 8.10++### 0.0.1.4 (2020-04-01)++- Support GHC 8.8+- Support `path` 0.7++### 0.0.1.2 (2018-11-22)++Support GHC 8.6++### 0.0.1.1 (2018-08-21)++Raise version bound to include base 4.11++### 0.0.1.0 (2017-12-13)++* Support more GHC versions+* Re-export `parseAbsFile` and `parseRelFile`++### 0.0.0.2 (2017-10-13)++### 0.0.0.1 (2017-10-13)++Initial release
license.txt view
@@ -1,4 +1,4 @@-Copyright 2017 Chris Martin+Copyright 2017 Mission Valley Software LLC  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
path-text-utf8.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0  name: path-text-utf8-version: 0.0.1.10+version: 0.0.1.11 category: Filesystem, Text  synopsis: Read and write UTF-8 text files@@ -10,32 +10,34 @@              packages, providing convenient functions to read and              write UTF-8 text files. -homepage:    https://github.com/chris-martin/path-text-utf8-bug-reports: https://github.com/chris-martin/path-text-utf8/issues+homepage:    https://github.com/typeclasses/path-text-utf8+bug-reports: https://github.com/typeclasses/path-text-utf8/issues -author:     Chris Martin <ch.martin@gmail.com>-maintainer: Chris Martin <ch.martin@gmail.com>+author: Chris Martin+maintainer: Chris Martin, Julie Moronuki +copyright: 2017 Mission Valley Software LLC license: Apache-2.0 license-file: license.txt -build-type: Simple+extra-source-files: *.md  source-repository head     type: git-    location: https://github.com/chris-martin/path-text-utf8+    location: https://github.com/typeclasses/path-text-utf8  library     default-language: Haskell2010     hs-source-dirs: src     ghc-options: -Wall+    default-extensions: BangPatterns NoImplicitPrelude      exposed-modules:         Path.Text.UTF8      build-depends:-        base ^>= 4.14 || ^>= 4.15 || ^>= 4.16-      , bytestring ^>= 0.10.6 || ^>= 0.11-      , path ^>= 0.8 || ^>= 0.9+      , base ^>= 4.14 || ^>= 4.15 || ^>= 4.16 || ^>= 4.17+      , bytestring ^>= 0.10.12 || ^>= 0.11+      , path ^>= 0.9.2       , safe-exceptions ^>= 0.1.7-      , text ^>= 1.2.2+      , text ^>= 1.2.4 || ^>= 2.0
src/Path/Text/UTF8.hs view
@@ -1,28 +1,17 @@-{-# LANGUAGE BangPatterns      #-}-{-# LANGUAGE NoImplicitPrelude #-}- -- | Read and write UTF-8 text files. module Path.Text.UTF8   (-  -- * Reading-    readFile-  , tryReadFile-  , ReadError (..)-  -- * Writing-  , writeFile-  , tryWriteFile-  , WriteError-  -- * Re-exports-  , IOError-  , UnicodeException (DecodeError)-  , parseAbsFile-  , parseRelFile-  ) where+    {- * Reading    -} readFile, tryReadFile, ReadError (..),+    {- * Writing    -} writeFile, tryWriteFile, WriteError,+    {- * Re-exports -} IOError, UnicodeException (DecodeError),+                       parseAbsFile, parseRelFile,+  )+  where  -- base-import Data.Either     (Either (..))-import Data.Functor    ((<$>))-import System.IO       (IO)+import Data.Either (Either (..))+import Data.Functor ((<$>))+import System.IO (IO) import System.IO.Error (IOError)  -- safe-exceptions@@ -32,57 +21,56 @@ import qualified Data.ByteString as BS  -- text-import           Data.Text                (Text)-import qualified Data.Text.Encoding       as TextEncoding-import           Data.Text.Encoding.Error (UnicodeException (..))+import Data.Text (Text)+import Data.Text.Encoding.Error (UnicodeException (..))+import qualified Data.Text.Encoding as TextEncoding  -- path-import           Path (Path, parseAbsFile, parseRelFile)+import Path (Path, parseAbsFile, parseRelFile) import qualified Path -data ReadError-  = ReadErrorIO IOError+data ReadError =+    ReadErrorIO IOError   | ReadErrorDecode UnicodeException  type WriteError = IOError --- | Read the contents of a UTF-8 encoded text file.------ May throw 'IOError' or 'UnicodeException'. To handle these errors in 'Either'--- instead, use 'tryReadFile'.+{-| Read the contents of a UTF-8 encoded text file++May throw 'IOError' or 'UnicodeException'. To handle these errors in 'Either'+instead, use 'tryReadFile'. -} readFile :: Path base Path.File -> IO Text readFile path =-  f <$> BS.readFile (Path.toFilePath path)+    f <$> BS.readFile (Path.toFilePath path)   where     f bs = let !text = TextEncoding.decodeUtf8 bs in text --- | Read the contents of a UTF-8 encoded text file.------ Any 'IOError' or 'UnicodeException' that occurs is caught and returned as a--- 'ReadError' on the 'Left' side of the 'Either'. To throw these exceptions--- instead, use 'readFile'.+{-| Read the contents of a UTF-8 encoded text file++Any 'IOError' or 'UnicodeException' that occurs is caught and returned as a+'ReadError' on the 'Left' side of the 'Either'. To throw these exceptions+instead, use 'readFile'. -} tryReadFile :: Path base Path.File -> IO (Either ReadError Text) tryReadFile path =-  f <$> Exception.tryIO (BS.readFile (Path.toFilePath path))+    f <$> Exception.tryIO (BS.readFile (Path.toFilePath path))   where     f (Left e) = Left (ReadErrorIO e)     f (Right bs) = first ReadErrorDecode (TextEncoding.decodeUtf8' bs) --- | Write text to a file in a UTF-8 encoding.------ May throw 'IOError'. To handle this error in 'Either' instead, use--- 'tryWriteFile'.+{-| Write text to a file in a UTF-8 encoding++May throw 'IOError'. To handle this error in 'Either' instead, use+'tryWriteFile'. -} writeFile :: Path base Path.File -> Text -> IO () writeFile path text =-  BS.writeFile (Path.toFilePath path) (TextEncoding.encodeUtf8 text)+    BS.writeFile (Path.toFilePath path) (TextEncoding.encodeUtf8 text) --- | Write text to a file in a UTF-8 encoding.------ Any 'IOError' that occurs is caught and returned on the 'Left' side of the--- 'Either'. To throw the exception instead, use 'writeFile'.+{-| Write text to a file in a UTF-8 encoding++Any 'IOError' that occurs is caught and returned on the 'Left' side of the+'Either'. To throw the exception instead, use 'writeFile'. -} tryWriteFile :: Path base Path.File -> Text -> IO (Either WriteError ())-tryWriteFile path text =-  Exception.tryIO (writeFile path text)+tryWriteFile path text = Exception.tryIO (writeFile path text)  first :: (a -> a') -> Either a b -> Either a' b first f (Left x) = Left (f x)