text-all 0.4.0.0 → 0.4.1.0
raw patch · 3 files changed
+79/−4 lines, 3 filesdep +bytestringdep +utf8-string
Dependencies added: bytestring, utf8-string
Files
- CHANGELOG.md +7/−0
- lib/Data/Text/All.hs +69/−3
- text-all.cabal +3/−1
CHANGELOG.md view
@@ -1,3 +1,10 @@+# 0.4.1.0++* Now `toString` and other functions work with `ByteString` as well. Lenient+ UTF-8 decoding is used.++* Added `toByteString` and `toLByteString`.+ # 0.4.0.0 * Dropped `text-show` entirely; now `show` works via `Prelude.show`, which is
lib/Data/Text/All.hs view
@@ -23,7 +23,10 @@ -- * Conversion -- $conversion- toStrict, toLazy, toBuilder, toString,+ toStrict, toLazy,+ toBuilder,+ toString,+ toByteString, toLByteString, -- * Showing -- $showing@@ -46,11 +49,19 @@ import Data.Text import Data.Text.IO import Data.Text.Encoding+import Data.Text.Encoding.Error import qualified Data.Text.Lazy.Builder as B import Data.Text.Lazy.Builder (Builder, flush) import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.Encoding as TL +import qualified Data.ByteString as BS+import qualified Data.ByteString.Lazy as BSL++import qualified Data.ByteString.UTF8 as UTF8+import qualified Data.ByteString.Lazy.UTF8 as UTF8L+ import Data.Text.Format hiding (format, print, hprint, build) import Data.Text.Format.Params import Data.Text.Buildable@@ -113,8 +124,9 @@ bformat = Format.build {-# INLINE bformat #-} -{- $conversion-These functions can convert from strict\/lazy 'Text', 'Builder', and 'String'.+{- $conversion These functions can convert from strict\/lazy 'Text', 'Builder',+'String', and strict\/lazy 'BS.ByteString' (in which case they use lenient+UTF-8 decoding). -} class ToStrict t where@@ -128,6 +140,12 @@ instance ToStrict Builder where toStrict = TL.toStrict . B.toLazyText {-# INLINE toStrict #-}+instance ToStrict BS.ByteString where+ toStrict = decodeUtf8With lenientDecode+ {-# INLINE toStrict #-}+instance ToStrict BSL.ByteString where+ toStrict = decodeUtf8With lenientDecode . BSL.toStrict+ {-# INLINE toStrict #-} class ToLazy t where toLazy :: t -> LText@@ -140,6 +158,12 @@ instance ToLazy Builder where toLazy = B.toLazyText {-# INLINE toLazy #-}+instance ToLazy BS.ByteString where+ toLazy = TL.fromStrict . decodeUtf8With lenientDecode+ {-# INLINE toLazy #-}+instance ToLazy BSL.ByteString where+ toLazy = TL.decodeUtf8With lenientDecode+ {-# INLINE toLazy #-} class ToBuilder t where toBuilder :: t -> Builder@@ -152,6 +176,12 @@ instance ToBuilder LText where toBuilder = B.fromLazyText {-# INLINE toBuilder #-}+instance ToBuilder BS.ByteString where+ toBuilder = B.fromText . decodeUtf8With lenientDecode+ {-# INLINE toBuilder #-}+instance ToBuilder BSL.ByteString where+ toBuilder = B.fromLazyText . TL.decodeUtf8With lenientDecode+ {-# INLINE toBuilder #-} class ToString t where toString :: t -> String@@ -164,6 +194,42 @@ instance ToString Builder where toString = TL.unpack . B.toLazyText {-# INLINE toString #-}+instance ToString BS.ByteString where+ toString = UTF8.toString+ {-# INLINE toString #-}+instance ToString BSL.ByteString where+ toString = UTF8L.toString+ {-# INLINE toString #-}++class ToByteString t where+ toByteString :: t -> BS.ByteString+instance ToByteString Text where+ toByteString = encodeUtf8+ {-# INLINE toByteString #-}+instance ToByteString LText where+ toByteString = encodeUtf8 . TL.toStrict+ {-# INLINE toByteString #-}+instance ToByteString Builder where+ toByteString = encodeUtf8 . TL.toStrict . B.toLazyText+ {-# INLINE toByteString #-}+instance (a ~ Char) => ToByteString [a] where+ toByteString = UTF8.fromString+ {-# INLINE toByteString #-}++class ToLByteString t where+ toLByteString :: t -> BSL.ByteString+instance ToLByteString Text where+ toLByteString = TL.encodeUtf8 . TL.fromStrict+ {-# INLINE toLByteString #-}+instance ToLByteString LText where+ toLByteString = TL.encodeUtf8+ {-# INLINE toLByteString #-}+instance ToLByteString Builder where+ toLByteString = TL.encodeUtf8 . B.toLazyText+ {-# INLINE toLByteString #-}+instance (a ~ Char) => ToLByteString [a] where+ toLByteString = UTF8L.fromString+ {-# INLINE toLByteString #-} -- | A 'Builder' producing a single character. bsingleton :: Char -> Builder
text-all.cabal view
@@ -1,5 +1,5 @@ name: text-all-version: 0.4.0.0+version: 0.4.1.0 synopsis: Everything Data.Text related in one package description: Everything @Data.Text@-related in one package.@@ -28,8 +28,10 @@ -- other-modules: -- other-extensions: build-depends: base >=4.5 && <5+ , bytestring , text ==1.2.2.* , text-format ==0.3.1.*+ , utf8-string ghc-options: -Wall -fno-warn-unused-do-bind hs-source-dirs: lib default-language: Haskell2010