nonempty-wrapper-text 0.1.0.0 → 0.1.1.0
raw patch · 7 files changed
+50/−41 lines, 7 filesdep ~textPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: text
API changes (from Hackage documentation)
+ Data.Text.Lazy.NonEmpty: elem :: Char -> NonEmptyLazyText -> Bool
+ Data.Text.NonEmpty: elem :: Char -> NonEmptyStrictText -> Bool
- Data.Text.Encoding.NonEmpty: Some :: Text -> ByteString -> (ByteString -> Decoding) -> Decoding
+ Data.Text.Encoding.NonEmpty: Some :: !Text -> !ByteString -> (ByteString -> Decoding) -> Decoding
- Data.Text.Lazy.NonEmpty: mapAccumL :: forall a. (a -> Char -> (a, Char)) -> a -> NonEmptyLazyText -> (a, NonEmptyLazyText)
+ Data.Text.Lazy.NonEmpty: mapAccumL :: (a -> Char -> (a, Char)) -> a -> NonEmptyLazyText -> (a, NonEmptyLazyText)
- Data.Text.Lazy.NonEmpty: mapAccumR :: forall a. (a -> Char -> (a, Char)) -> a -> NonEmptyLazyText -> (a, NonEmptyLazyText)
+ Data.Text.Lazy.NonEmpty: mapAccumR :: (a -> Char -> (a, Char)) -> a -> NonEmptyLazyText -> (a, NonEmptyLazyText)
- Data.Text.NonEmpty: mapAccumL :: forall a. (a -> Char -> (a, Char)) -> a -> NonEmptyStrictText -> (a, NonEmptyStrictText)
+ Data.Text.NonEmpty: mapAccumL :: (a -> Char -> (a, Char)) -> a -> NonEmptyStrictText -> (a, NonEmptyStrictText)
- Data.Text.NonEmpty: mapAccumR :: forall a. (a -> Char -> (a, Char)) -> a -> NonEmptyStrictText -> (a, NonEmptyStrictText)
+ Data.Text.NonEmpty: mapAccumR :: (a -> Char -> (a, Char)) -> a -> NonEmptyStrictText -> (a, NonEmptyStrictText)
Files
- LICENSE +1/−1
- README.md +11/−0
- changelog.md +3/−0
- nonempty-wrapper-text.cabal +7/−4
- src/Data/Text/Encoding/NonEmpty.hs +10/−8
- src/Data/Text/Lazy/NonEmpty.hs +9/−14
- src/Data/Text/NonEmpty.hs +9/−14
LICENSE view
@@ -1,6 +1,6 @@ ISC License -Copyright (c) 2022 Gautier DI FOLCO+Copyright (c) 2022-2025 Gautier DI FOLCO Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above
+ README.md view
@@ -0,0 +1,11 @@+# nonempty-wrapper-text++Create NonEmpty version of any container.++`text` `instance`s and functions.++## Example:++```+type NonEmptyText = NonEmpty Text+```
+ changelog.md view
@@ -0,0 +1,3 @@+# 0.1.1.0++* Drop `text-1.*` support
nonempty-wrapper-text.cabal view
@@ -1,8 +1,11 @@ cabal-version: 3.0 name: nonempty-wrapper-text-version: 0.1.0.0+version: 0.1.1.0+extra-doc-files:+ README.md+ changelog.md author: Gautier DI FOLCO-maintainer: gautier.difolco@gmail.com+maintainer: foss@difolco.dev category: Data build-type: Simple license: ISC@@ -10,13 +13,13 @@ synopsis: 'NonEmpty' wrappers for text description: 'NonEmpty' wrappers for text. Homepage: http://github.com/blackheaven/nonempty-wrapper/nonempty-wrapper-text-tested-with: GHC==9.2.2, GHC==9.0.2, GHC==8.10.7+tested-with: GHC==9.12.1, GHC==9.10.2, GHC==9.8.4, GHC==9.6.7, GHC==9.4.8, GHC==9.2.8 library default-language: Haskell2010 build-depends: base == 4.*- , text >=1 && < 3+ , text == 2.* , bytestring >= 0.10 && < 0.13 , nonempty-wrapper >= 0.1.0.0 && < 1 hs-source-dirs: src
src/Data/Text/Encoding/NonEmpty.hs view
@@ -1,9 +1,11 @@+{-# OPTIONS_GHC -Wno-redundant-constraints #-}+ -- | -- Module : Data.Text.Encoding.NonEmpty -- Copyright : Gautier DI FOLCO--- License : BSD2+-- License : ISC ----- Maintainer : Gautier DI FOLCO <gautier.difolco@gmail.com>+-- Maintainer : Gautier DI FOLCO <foss@difolco.dev> -- Stability : Unstable -- Portability : GHC --@@ -73,11 +75,11 @@ -- | Decode a 'ByteString' containing Latin-1 (aka ISO-8859-1) encoded text. -- -- 'decodeLatin1' is semantically equivalent to--- @Data.Text.pack . Data.ByteString.Char8.unpack@+-- @Data.Text.pack . Data.ByteString.Char8.unpack@ -- -- This is a total function. However, bear in mind that decoding Latin-1 (non-ASCII) -- characters to UTf-8 requires actual work and is not just buffer copying.-decodeLatin1 :: HasCallStack => NonEmpty ByteString -> NonEmptyStrictText+decodeLatin1 :: (HasCallStack) => NonEmpty ByteString -> NonEmptyStrictText decodeLatin1 = overNonEmpty E.decodeLatin1 {-# INLINE decodeLatin1 #-} @@ -85,7 +87,7 @@ -- -- Surrogate code points in replacement character returned by 'OnDecodeError' -- will be automatically remapped to the replacement char @U+FFFD@.-decodeUtf8With :: HasCallStack => OnDecodeError -> NonEmpty ByteString -> NonEmptyStrictText+decodeUtf8With :: (HasCallStack) => OnDecodeError -> NonEmpty ByteString -> NonEmptyStrictText decodeUtf8With onError = overNonEmpty $ E.decodeUtf8With onError {-# INLINE decodeUtf8With #-} @@ -96,13 +98,13 @@ -- thrown (either by this function or a continuation) that cannot be -- caught in pure code. For more control over the handling of invalid -- data, use 'streamDecodeUtf8With'.-streamDecodeUtf8 :: HasCallStack => NonEmpty ByteString -> NonEmpty E.Decoding+streamDecodeUtf8 :: (HasCallStack) => NonEmpty ByteString -> NonEmpty E.Decoding streamDecodeUtf8 = overNonEmpty E.streamDecodeUtf8 {-# INLINE streamDecodeUtf8 #-} -- | Decode, in a stream oriented way, a lazy 'ByteString' containing UTF-8 -- encoded text.-streamDecodeUtf8With :: HasCallStack => OnDecodeError -> NonEmpty ByteString -> NonEmpty E.Decoding+streamDecodeUtf8With :: (HasCallStack) => OnDecodeError -> NonEmpty ByteString -> NonEmpty E.Decoding streamDecodeUtf8With onError = overNonEmpty $ E.streamDecodeUtf8With onError {-# INLINE streamDecodeUtf8With #-} @@ -124,7 +126,7 @@ -- -- If the input contains any invalid UTF-8 data, the relevant -- exception will be returned, otherwise the decoded text.-decodeUtf8' :: HasCallStack => NonEmpty ByteString -> Either UnicodeException NonEmptyStrictText+decodeUtf8' :: (HasCallStack) => NonEmpty ByteString -> Either UnicodeException NonEmptyStrictText decodeUtf8' = fmap trustedNonEmpty . E.decodeUtf8' . getNonEmpty {-# INLINE decodeUtf8' #-}
src/Data/Text/Lazy/NonEmpty.hs view
@@ -1,13 +1,12 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-redundant-constraints #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | -- Module : Data.Text.Lazy.NonEmpty -- Copyright : Gautier DI FOLCO--- License : BSD2+-- License : ISC ----- Maintainer : Gautier DI FOLCO <gautier.difolco@gmail.com>+-- Maintainer : Gautier DI FOLCO <foss@difolco.dev> -- Stability : Unstable -- Portability : GHC --@@ -147,9 +146,7 @@ filter, breakOnAll, find,-#if MIN_VERSION_text(1,2,5) elem,-#endif partition, -- * Indexing@@ -192,7 +189,7 @@ {-# INLINE pack #-} -- | /O(n)/ Convert a 'NonEmptyStrictText' into a 'NonEmpty String'.-unpack :: HasCallStack => NonEmptyLazyText -> NonEmpty String+unpack :: (HasCallStack) => NonEmptyLazyText -> NonEmpty String unpack = overNonEmpty T.unpack {-# INLINE unpack #-} @@ -338,7 +335,7 @@ -- -- >>> T.reverse "desrever" -- "reversed"-reverse :: HasCallStack => NonEmptyLazyText -> NonEmptyLazyText+reverse :: (HasCallStack) => NonEmptyLazyText -> NonEmptyLazyText reverse = overNonEmpty T.reverse {-# INLINE reverse #-} @@ -349,7 +346,7 @@ -- -- @ -- replace needle replacement haystack =--- 'intercalate' replacement ('splitOn' needle haystack)+-- 'intercalate' replacement ('splitOn' needle haystack) -- @ -- -- As this suggests, each occurrence is replaced exactly once. So if@@ -921,11 +918,9 @@ -- | /O(n)/ The 'elem' function takes a character and a 'NonEmptyLazyText', and -- returns 'True' if the element is found in the given 'NonEmptyLazyText', or -- 'False' otherwise.-#if MIN_VERSION_text(1,2,5) elem :: Char -> NonEmptyLazyText -> Bool elem p = T.elem p . getNonEmpty {-# INLINE elem #-}-#endif -- | /O(n)/ The 'find' function takes a predicate and a 'NonEmptyLazyText', and -- returns the first element matching the predicate, or 'Nothing' if@@ -1040,7 +1035,7 @@ -- before and after that index, you would instead use @breakOnAll \"::\"@. -- | /O(n)/ 'NonEmptyLazyText' index (subscript) operator, starting from 0.-index :: HasCallStack => NonEmptyLazyText -> Int64 -> Char+index :: (HasCallStack) => NonEmptyLazyText -> Int64 -> Char index x = T.index (getNonEmpty x) {-# INLINE index #-} @@ -1116,7 +1111,7 @@ -- -- In (unlikely) bad cases, this function's time complexity degrades -- towards /O(n*m)/.-isInfixOf :: HasCallStack => NonEmptyLazyText -> NonEmptyLazyText -> Bool+isInfixOf :: (HasCallStack) => NonEmptyLazyText -> NonEmptyLazyText -> Bool isInfixOf = T.isInfixOf `on` getNonEmpty {-# INLINE isInfixOf #-} @@ -1141,7 +1136,7 @@ -- This is particularly useful with the @ViewPatterns@ extension to -- GHC, as follows: ----- > {-# LANGUAGE ViewPatterns #-}+-- > {\-# LANGUAGE ViewPatterns #-\} -- > import Data.Text.NonEmpty as T -- > -- > fnordLength :: NonEmptyLazyText -> Int@@ -1189,7 +1184,7 @@ -- This is particularly useful with the @ViewPatterns@ extension to -- GHC, as follows: ----- > {-# LANGUAGE ViewPatterns #-}+-- > {\-# LANGUAGE ViewPatterns #-\} -- > import Data.Text.NonEmpty as T -- > -- > quuxLength :: NonEmptyLazyText -> Int
src/Data/Text/NonEmpty.hs view
@@ -1,13 +1,12 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-redundant-constraints #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | -- Module : Data.Text.NonEmpty -- Copyright : Gautier DI FOLCO--- License : BSD2+-- License : ISC ----- Maintainer : Gautier DI FOLCO <gautier.difolco@gmail.com>+-- Maintainer : Gautier DI FOLCO <foss@difolco.dev> -- Stability : Unstable -- Portability : GHC --@@ -141,9 +140,7 @@ filter, breakOnAll, find,-#if MIN_VERSION_text(1,2,5) elem,-#endif partition, -- * Indexing@@ -185,7 +182,7 @@ {-# INLINE pack #-} -- | /O(n)/ Convert a 'NonEmptyStrictText' into a 'NonEmpty String'.-unpack :: HasCallStack => NonEmptyStrictText -> NonEmpty String+unpack :: (HasCallStack) => NonEmptyStrictText -> NonEmpty String unpack = overNonEmpty T.unpack {-# INLINE unpack #-} @@ -311,7 +308,7 @@ -- -- >>> T.reverse "desrever" -- "reversed"-reverse :: HasCallStack => NonEmptyStrictText -> NonEmptyStrictText+reverse :: (HasCallStack) => NonEmptyStrictText -> NonEmptyStrictText reverse = overNonEmpty T.reverse {-# INLINE reverse #-} @@ -322,7 +319,7 @@ -- -- @ -- replace needle replacement haystack =--- 'intercalate' replacement ('splitOn' needle haystack)+-- 'intercalate' replacement ('splitOn' needle haystack) -- @ -- -- As this suggests, each occurrence is replaced exactly once. So if@@ -880,11 +877,9 @@ -- | /O(n)/ The 'elem' function takes a character and a 'NonEmptyStrictText', and -- returns 'True' if the element is found in the given 'NonEmptyStrictText', or -- 'False' otherwise.-#if MIN_VERSION_text(1,2,5) elem :: Char -> NonEmptyStrictText -> Bool elem p = T.elem p . getNonEmpty {-# INLINE elem #-}-#endif -- | /O(n)/ The 'find' function takes a predicate and a 'NonEmptyStrictText', and -- returns the first element matching the predicate, or 'Nothing' if@@ -999,7 +994,7 @@ -- before and after that index, you would instead use @breakOnAll \"::\"@. -- | /O(n)/ 'NonEmptyStrictText' index (subscript) operator, starting from 0.-index :: HasCallStack => NonEmptyStrictText -> Int -> Char+index :: (HasCallStack) => NonEmptyStrictText -> Int -> Char index x = T.index (getNonEmpty x) {-# INLINE index #-} @@ -1082,7 +1077,7 @@ -- -- In (unlikely) bad cases, this function's time complexity degrades -- towards /O(n*m)/.-isInfixOf :: HasCallStack => NonEmptyStrictText -> NonEmptyStrictText -> Bool+isInfixOf :: (HasCallStack) => NonEmptyStrictText -> NonEmptyStrictText -> Bool isInfixOf = T.isInfixOf `on` getNonEmpty {-# INLINE isInfixOf #-} @@ -1107,7 +1102,7 @@ -- This is particularly useful with the @ViewPatterns@ extension to -- GHC, as follows: ----- > {-# LANGUAGE ViewPatterns #-}+-- > {\-# LANGUAGE ViewPatterns #-\} -- > import Data.Text.NonEmpty as T -- > -- > fnordLength :: NonEmptyStrictText -> Int@@ -1155,7 +1150,7 @@ -- This is particularly useful with the @ViewPatterns@ extension to -- GHC, as follows: ----- > {-# LANGUAGE ViewPatterns #-}+-- > {\-# LANGUAGE ViewPatterns #-\} -- > import Data.Text.NonEmpty as T -- > -- > quuxLength :: NonEmptyStrictText -> Int