packages feed

string-transform 1.1.0 → 1.1.1

raw patch · 4 files changed

+100/−85 lines, 4 files

Files

− README.md
@@ -1,19 +0,0 @@-# string-transform--[![Build Status](https://travis-ci.org/ncaq/string-transform.svg?branch=master)](https://travis-ci.org/ncaq/string-transform)-![Hackage](https://img.shields.io/hackage/v/string-transform.svg)--simple and easy haskell string transform wrapper.--# provide function--* `toString`-* `toByteStringStrict`-* `toByteStringLazy`-* `toShortByteString`-* `toTextStrict`-* `toTextLazy`--# note--It wrapper expect that `ByteString` encode is utf-8.
src/Data/String/Transform.hs view
@@ -13,127 +13,163 @@ import qualified Data.Text.Lazy.Encoding   as TL  class ToString a where-    toString :: a -> String+  toString :: a -> String  instance ToString String where-    toString = id+  toString = id+  {-# INLINE toString #-}  instance ToString B.ByteString where-    toString = BU.toString+  toString = BU.toString+  {-# INLINE toString #-}  instance ToString BL.ByteString where-    toString = BLU.toString+  toString = BLU.toString+  {-# INLINE toString #-}  instance ToString BS.ShortByteString where-    toString = toString . BS.fromShort+  toString = toString . BS.fromShort+  {-# INLINE toString #-}  instance ToString T.Text where-    toString = T.unpack+  toString = T.unpack+  {-# INLINE toString #-}  instance ToString TL.Text where-    toString = TL.unpack+  toString = TL.unpack+  {-# INLINE toString #-}  class ToByteStringStrict a where-    toByteStringStrict :: a -> B.ByteString+  toByteStringStrict :: a -> B.ByteString  instance ToByteStringStrict String where-    toByteStringStrict = BU.fromString+  toByteStringStrict = BU.fromString+  {-# INLINE toByteStringStrict #-}  instance ToByteStringStrict B.ByteString where-    toByteStringStrict = id+  toByteStringStrict = id+  {-# INLINE toByteStringStrict #-}  instance ToByteStringStrict BL.ByteString where-    toByteStringStrict = BL.toStrict+  toByteStringStrict = BL.toStrict+  {-# INLINE toByteStringStrict #-}  instance ToByteStringStrict BS.ShortByteString where-    toByteStringStrict = BS.fromShort+  toByteStringStrict = BS.fromShort+  {-# INLINE toByteStringStrict #-}  instance ToByteStringStrict T.Text where-    toByteStringStrict = T.encodeUtf8+  toByteStringStrict = T.encodeUtf8+  {-# INLINE toByteStringStrict #-}  instance ToByteStringStrict TL.Text where-    toByteStringStrict = toByteStringStrict . TL.toStrict+  toByteStringStrict = toByteStringStrict . TL.toStrict+  {-# INLINE toByteStringStrict #-}  class ToByteStringLazy a where-    toByteStringLazy :: a -> BL.ByteString+  toByteStringLazy :: a -> BL.ByteString  instance ToByteStringLazy String where-    toByteStringLazy = BLU.fromString+  toByteStringLazy = BLU.fromString+  {-# INLINE toByteStringLazy #-}  instance ToByteStringLazy B.ByteString where-    toByteStringLazy = BL.fromStrict+  toByteStringLazy = BL.fromStrict+  {-# INLINE toByteStringLazy #-}  instance ToByteStringLazy BL.ByteString where-    toByteStringLazy = id+  toByteStringLazy = id+  {-# INLINE toByteStringLazy #-}  instance ToByteStringLazy BS.ShortByteString where-    toByteStringLazy = toByteStringLazy . BS.fromShort+  toByteStringLazy = toByteStringLazy . BS.fromShort+  {-# INLINE toByteStringLazy #-}  instance ToByteStringLazy T.Text where-    toByteStringLazy = toByteStringLazy . T.encodeUtf8+  toByteStringLazy = toByteStringLazy . T.encodeUtf8+  {-# INLINE toByteStringLazy #-}  instance ToByteStringLazy TL.Text where-    toByteStringLazy = TL.encodeUtf8+  toByteStringLazy = TL.encodeUtf8+  {-# INLINE toByteStringLazy #-}  class ToShortByteString a where-    toShortByteString :: a -> BS.ShortByteString+  toShortByteString :: a -> BS.ShortByteString  instance ToShortByteString String where-    toShortByteString = toShortByteString . BU.fromString+  toShortByteString = toShortByteString . BU.fromString+  {-# INLINE toShortByteString #-}  instance ToShortByteString B.ByteString where-    toShortByteString = BS.toShort+  toShortByteString = BS.toShort+  {-# INLINE toShortByteString #-}  instance ToShortByteString BL.ByteString where-    toShortByteString = toShortByteString . toByteStringStrict+  toShortByteString = toShortByteString . toByteStringStrict+  {-# INLINE toShortByteString #-}  instance ToShortByteString BS.ShortByteString where-    toShortByteString = id+  toShortByteString = id+  {-# INLINE toShortByteString #-}  instance ToShortByteString T.Text where-    toShortByteString = toShortByteString . toByteStringStrict+  toShortByteString = toShortByteString . toByteStringStrict+  {-# INLINE toShortByteString #-}  instance ToShortByteString TL.Text where-    toShortByteString = toShortByteString . toByteStringStrict+  toShortByteString = toShortByteString . toByteStringStrict+  {-# INLINE toShortByteString #-}  class ToTextStrict a where-    toTextStrict :: a -> T.Text+  toTextStrict :: a -> T.Text  instance ToTextStrict String where-    toTextStrict = T.pack+  toTextStrict = T.pack+  {-# INLINE toTextStrict #-}  instance ToTextStrict B.ByteString where-    toTextStrict = T.decodeUtf8+  toTextStrict = T.decodeUtf8+  {-# INLINE toTextStrict #-}  instance ToTextStrict BL.ByteString where-    toTextStrict = toTextStrict . BL.toStrict+  toTextStrict = toTextStrict . BL.toStrict+  {-# INLINE toTextStrict #-}  instance ToTextStrict BS.ShortByteString where-    toTextStrict = toTextStrict . BS.fromShort+  toTextStrict = toTextStrict . BS.fromShort+  {-# INLINE toTextStrict #-}  instance ToTextStrict T.Text where-    toTextStrict = id+  toTextStrict = id+  {-# INLINE toTextStrict #-}  instance ToTextStrict TL.Text where-    toTextStrict = TL.toStrict+  toTextStrict = TL.toStrict+  {-# INLINE toTextStrict #-}  class ToTextLazy a where-    toTextLazy :: a -> TL.Text+  toTextLazy :: a -> TL.Text  instance ToTextLazy String where-    toTextLazy = TL.pack+  toTextLazy = TL.pack+  {-# INLINE toTextLazy #-}  instance ToTextLazy B.ByteString where-    toTextLazy = toTextLazy . BL.fromStrict+  toTextLazy = toTextLazy . BL.fromStrict+  {-# INLINE toTextLazy #-}  instance ToTextLazy BL.ByteString where-    toTextLazy = TL.decodeUtf8+  toTextLazy = TL.decodeUtf8+  {-# INLINE toTextLazy #-}  instance ToTextLazy BS.ShortByteString where-    toTextLazy = toTextLazy . toByteStringLazy+  toTextLazy = toTextLazy . toByteStringLazy+  {-# INLINE toTextLazy #-}  instance ToTextLazy T.Text where-    toTextLazy = TL.fromStrict+  toTextLazy = TL.fromStrict+  {-# INLINE toTextLazy #-}  instance ToTextLazy TL.Text where-    toTextLazy = id+  toTextLazy = id+  {-# INLINE toTextLazy #-}
string-transform.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.20.0.+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: 5a82efa09e7668f37427521f7a85c669e793d5cbbb964ee5703aa1e9f4e66924+-- hash: 4c0ad1d9ab8cad57c5a30c4152e3b0e7b2af0289c1feee194896ce204636a566  name:           string-transform-version:        1.1.0+version:        1.1.1 synopsis:       simple and easy haskell string transform wrapper category:       Text homepage:       https://github.com/ncaq/string-transform#readme@@ -16,11 +18,7 @@ license:        MIT license-file:   LICENSE build-type:     Simple-cabal-version:  >= 1.10 -extra-source-files:-    README.md- source-repository head   type: git   location: https://github.com/ncaq/string-transform@@ -28,7 +26,7 @@ library   hs-source-dirs:       src-  ghc-options: -Wall+  ghc-options: -Wall -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-exported-signatures -Wmissing-home-modules -Wredundant-constraints -Wcompat   build-depends:       base >=4.7 && <5     , bytestring@@ -45,7 +43,7 @@   main-is: Main.hs   hs-source-dirs:       test-  ghc-options: -Wall+  ghc-options: -Wall -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-exported-signatures -Wmissing-home-modules -Wredundant-constraints -Wcompat   build-depends:       base >=4.7 && <5     , bytestring
test/Main.hs view
@@ -11,32 +11,32 @@ main = defaultMain $ testGroup "all-tests" tests  tests :: [TestTree]-tests =-    [ testGroup "SmallCheck" smallCheckTest+tests+  = [ testGroup "SmallCheck" smallCheckTest     , testGroup "Unit tests" hunitTest     ]  smallCheckTest :: [TestTree]-smallCheckTest =-    [ testProperty "s == toString (toByteStringStrict s)"-        (\(s :: String) -> s == toString (toByteStringStrict s))+smallCheckTest+  = [ testProperty "s == toString (toByteStringStrict s)"+      (\(s :: String) -> s == toString (toByteStringStrict s))     , testProperty "s == toString (toByteStringLazy s)"-        (\(s :: String) -> s == toString (toByteStringLazy s))+      (\(s :: String) -> s == toString (toByteStringLazy s))     , testProperty "s == toString (toShortByteString s)"-        (\(s :: String) -> s == toString (toShortByteString s))+      (\(s :: String) -> s == toString (toShortByteString s))     , testProperty "s == toString (toTextStrict s)"-        (\(s :: String) -> s == toString (toTextStrict s))+      (\(s :: String) -> s == toString (toTextStrict s))     , testProperty "s == toString (toTextLazy s)"-        (\(s :: String) -> s == toString (toTextLazy s))+      (\(s :: String) -> s == toString (toTextLazy s))     , testProperty "a == b ⇔ toByteStringStrict a == toByteStringStrict b"-        (\(a :: String) (b :: String) ->-             let p = a == b-                 q = toByteStringStrict a == toByteStringStrict b-             in p == q)+      (\(a :: String) (b :: String) ->+          let p = a == b+              q = toByteStringStrict a == toByteStringStrict b+          in p == q)     ]  hunitTest :: [TestTree]-hunitTest =-    [ testCase "toByteStringStrict 日本語" (toString (toByteStringStrict "日本語") @?= "日本語")+hunitTest+  = [ testCase "toByteStringStrict 日本語" (toString (toByteStringStrict "日本語") @?= "日本語")     , testCase "toString Text" (toString (T.pack "foo") @?= "foo")     ]