packages feed

string-transform 1.0.0 → 1.1.0

raw patch · 4 files changed

+46/−6 lines, 4 files

Files

README.md view
@@ -10,6 +10,7 @@ * `toString` * `toByteStringStrict` * `toByteStringLazy`+* `toShortByteString` * `toTextStrict` * `toTextLazy` 
src/Data/String/Transform.hs view
@@ -5,6 +5,7 @@ import qualified Data.ByteString           as B import qualified Data.ByteString.Lazy      as BL import qualified Data.ByteString.Lazy.UTF8 as BLU+import qualified Data.ByteString.Short     as BS import qualified Data.ByteString.UTF8      as BU import qualified Data.Text                 as T import qualified Data.Text.Encoding        as T@@ -23,6 +24,9 @@ instance ToString BL.ByteString where     toString = BLU.toString +instance ToString BS.ShortByteString where+    toString = toString . BS.fromShort+ instance ToString T.Text where     toString = T.unpack @@ -41,11 +45,14 @@ instance ToByteStringStrict BL.ByteString where     toByteStringStrict = BL.toStrict +instance ToByteStringStrict BS.ShortByteString where+    toByteStringStrict = BS.fromShort+ instance ToByteStringStrict T.Text where     toByteStringStrict = T.encodeUtf8  instance ToByteStringStrict TL.Text where-    toByteStringStrict = T.encodeUtf8 . TL.toStrict+    toByteStringStrict = toByteStringStrict . TL.toStrict  class ToByteStringLazy a where     toByteStringLazy :: a -> BL.ByteString@@ -59,12 +66,36 @@ instance ToByteStringLazy BL.ByteString where     toByteStringLazy = id +instance ToByteStringLazy BS.ShortByteString where+    toByteStringLazy = toByteStringLazy . BS.fromShort+ instance ToByteStringLazy T.Text where-    toByteStringLazy = BL.fromStrict . T.encodeUtf8+    toByteStringLazy = toByteStringLazy . T.encodeUtf8  instance ToByteStringLazy TL.Text where     toByteStringLazy = TL.encodeUtf8 +class ToShortByteString a where+    toShortByteString :: a -> BS.ShortByteString++instance ToShortByteString String where+    toShortByteString = toShortByteString . BU.fromString++instance ToShortByteString B.ByteString where+    toShortByteString = BS.toShort++instance ToShortByteString BL.ByteString where+    toShortByteString = toShortByteString . toByteStringStrict++instance ToShortByteString BS.ShortByteString where+    toShortByteString = id++instance ToShortByteString T.Text where+    toShortByteString = toShortByteString . toByteStringStrict++instance ToShortByteString TL.Text where+    toShortByteString = toShortByteString . toByteStringStrict+ class ToTextStrict a where     toTextStrict :: a -> T.Text @@ -75,8 +106,11 @@     toTextStrict = T.decodeUtf8  instance ToTextStrict BL.ByteString where-    toTextStrict = T.decodeUtf8 . BL.toStrict+    toTextStrict = toTextStrict . BL.toStrict +instance ToTextStrict BS.ShortByteString where+    toTextStrict = toTextStrict . BS.fromShort+ instance ToTextStrict T.Text where     toTextStrict = id @@ -90,10 +124,13 @@     toTextLazy = TL.pack  instance ToTextLazy B.ByteString where-    toTextLazy = TL.decodeUtf8 . BL.fromStrict+    toTextLazy = toTextLazy . BL.fromStrict  instance ToTextLazy BL.ByteString where     toTextLazy = TL.decodeUtf8++instance ToTextLazy BS.ShortByteString where+    toTextLazy = toTextLazy . toByteStringLazy  instance ToTextLazy T.Text where     toTextLazy = TL.fromStrict
string-transform.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 10c7428acad18e515f62c216dcb0bc6cad9e81752e160a9e57de4360029d19ad+-- hash: 5a82efa09e7668f37427521f7a85c669e793d5cbbb964ee5703aa1e9f4e66924  name:           string-transform-version:        1.0.0+version:        1.1.0 synopsis:       simple and easy haskell string transform wrapper category:       Text homepage:       https://github.com/ncaq/string-transform#readme
test/Main.hs view
@@ -22,6 +22,8 @@         (\(s :: String) -> s == toString (toByteStringStrict s))     , testProperty "s == toString (toByteStringLazy s)"         (\(s :: String) -> s == toString (toByteStringLazy s))+    , testProperty "s == toString (toShortByteString s)"+        (\(s :: String) -> s == toString (toShortByteString s))     , testProperty "s == toString (toTextStrict s)"         (\(s :: String) -> s == toString (toTextStrict s))     , testProperty "s == toString (toTextLazy s)"