packages feed

text-ascii 1.0.1 → 1.1

raw patch · 5 files changed

+59/−14 lines, 5 filesdep ~basedep ~template-haskellPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, template-haskell

API changes (from Hackage documentation)

+ Text.Ascii: eitherFromByteString :: ByteString -> Either Word8 AsciiText
+ Text.Ascii: eitherFromText :: Text -> Either Char AsciiText
- Text.Ascii.Unsafe: Unsafe :: a -> Unsafe
+ Text.Ascii.Unsafe: Unsafe :: a -> Unsafe (a :: Type)
- Text.Ascii.Unsafe: [safe] :: Unsafe -> a
+ Text.Ascii.Unsafe: [safe] :: Unsafe (a :: Type) -> a

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Revision history for text-ascii +## 1.0 -- 2021-10-31++* Support GHC 9.2.+* Remove support for GHCs below 8.10.+* Add `eitherFromText` and `eitherFromByteString` for better conversion errors.+ ## 1.0.1 -- 2021-03-02  * Support GHC 9.
README.md view
@@ -1,4 +1,4 @@-# `text-ascii`+# `text-ascii` [![Hackage](https://img.shields.io/hackage/v/text-ascii?style=flat-square)][hackage]  ## What is this thing? @@ -50,12 +50,11 @@  ## What does this run on? -Currently, our CI checks the following versions of GHC:+We support the latest three releases of GHC. Currently, these are: -* 8.6.5-* 8.8.4 * 8.10.4 * 9.0.1+* 9.2.1  We check on the following platforms: @@ -63,8 +62,13 @@ * Linux * MacOS +Currently, there is no support for GHC 9.2.1 with Windows in our CI. We will fix+this as soon as possible.+ ## What can I do with this?  The project is licensed Apache 2.0 (SPDX code [`Apache-2.0`](https://spdx.org/licenses/Apache-2.0.html)). For more details, please see the `LICENSE.md` file.++[hackage]: https://hackage.haskell.org/package/text-ascii
src/Text/Ascii.hs view
@@ -133,7 +133,9 @@      -- * Conversions     fromText,+    eitherFromText,     fromByteString,+    eitherFromByteString,     toText,     toByteString, @@ -1930,6 +1932,22 @@   Nothing -> pure . AsciiText . encodeUtf8 $ t   Just _ -> Nothing +-- | Try and convert a 'Text' into an 'AsciiText'. Gives @'Prelude.Left' c@ if the 'Text'+-- contains a 'Prelude.Char' @c@ that lacks an ASCII representation.+--+-- >>> eitherFromText "catboy"+-- Right "catboy"+-- >>> eitherFromText "😺😺😺😺😺"+-- Left '\128570'+--+-- /Complexity:/ \(\Theta(n)\)+--+-- @since 1.1+eitherFromText :: Text -> P.Either P.Char AsciiText+eitherFromText t = case T.find (not . isAscii) t of+  Nothing -> pure . AsciiText . encodeUtf8 $ t+  Just c -> P.Left c+ -- | Try and convert a 'ByteString' into an 'AsciiText'. Gives 'Nothing' if the -- 'ByteString' contains any bytes outside the ASCII range (that is, from 0 to -- 127 inclusive).@@ -1946,6 +1964,23 @@ fromByteString bs = case BS.find (> 127) bs of   Nothing -> pure . AsciiText $ bs   Just _ -> Nothing++-- | Try and convert a 'ByteString' into an 'AsciiText'. Gives @'Prelude.Left' w8@ if+-- the 'ByteString' contains a byte @w8@ that is outside the ASCII range (that+-- is, from 0 to 127 inclusive).+--+-- >>> eitherFromByteString "catboy"+-- Right "catboy"+-- >>> eitherFromByteString . BS.pack $ [128]+-- Left 128+--+-- /Complexity:/ \(\Theta(n)\)+--+-- @since 1.1+eitherFromByteString :: ByteString -> P.Either Word8 AsciiText+eitherFromByteString bs = case BS.find (> 127) bs of+  Nothing -> pure . AsciiText $ bs+  Just w8 -> P.Left w8  -- | Convert an 'AsciiText' into a 'Text' (by copying). --
src/Text/Ascii/Unsafe.hs view
@@ -71,10 +71,10 @@ -- | A wrapper for a type, designating that partial type class methods or other -- functions are available for it. ----- The role of 'Unsafe''s type argument is set to nominal. Among other things,--- it means that this type can't be coerced or derived through. This ensures--- clear indication when (and to what extent) non-total operations occur in any--- code using them.+-- We set the role of the type argument of 'Unsafe' to nominal. Among other+-- things, it means that this type can't be coerced or derived through. This+-- ensures clear indication when (and to what extent) non-total operations occur+-- in any code using them. -- -- @since 1.0.1 newtype Unsafe (a :: Type) = Unsafe {safe :: a}
text-ascii.cabal view
@@ -1,20 +1,20 @@ cabal-version:      3.0 name:               text-ascii-version:            1.0.1+version:            1.1 synopsis:           ASCII string and character processing. description:   A total-by-default, tested and documented library for   working with ASCII text. Low on dependencies , high on usability. -homepage:           https://github.org/kozross/text-ascii+homepage:           https://github.com/haskell-text/text-ascii license:            Apache-2.0 license-file:       LICENSE.md author:             Koz Ross maintainer:         koz.ross@retro-freedom.nz-bug-reports:        https://github.org/kozross/text-ascii/issues+bug-reports:        https://github.com/haskell-text/text-ascii/issues copyright:          (C) Koz Ross 2021 category:           Text-tested-with:        GHC ==8.6.5 || ==8.8.4 || ==8.10.3 || ==9.0.1+tested-with:        GHC ==8.10.5 || ==9.0.1 || ==9.2.1 build-type:         Simple extra-source-files:   CHANGELOG.md@@ -29,7 +29,7 @@     Text.Ascii.Unsafe    build-depends:-    , base              >=4.12     && <5+    , base              >=4.14     && <5     , bytestring        ^>=0.11.0.0     , case-insensitive  ^>=1.2.1.0     , deepseq           ^>=1.4.0.0@@ -37,7 +37,7 @@     , megaparsec        ^>=9.0.1     , optics-core       ^>=0.4     , optics-extra      ^>=0.4-    , template-haskell  >=2.14.0.0 && <3.0.0.0+    , template-haskell  >=2.16.0.0 && <3.0.0.0     , text              ^>=1.2.4.1    ghc-options: