string-interpolate 0.2.0.2 → 0.2.0.3
raw patch · 5 files changed
+97/−84 lines, 5 filesdep −interpolatedstring-perl6
Dependencies removed: interpolatedstring-perl6
Files
- CHANGELOG.md +5/−0
- README.md +2/−2
- bench/Bench.hs +21/−21
- src/lib/Data/String/Interpolate/Conversion.hs +12/−6
- string-interpolate.cabal +57/−55
CHANGELOG.md view
@@ -2,6 +2,11 @@ ## Unreleased +## v0.2.0.3 (2020-04-26)+++ Commented out `interpolatedstring-perl6` benchmarks, since that library+ does not build on GHC 8.8.2+ ## v0.2.0.2 (2020-04-25) + Updated interpolation parser to use enabled language extensions
README.md view
@@ -238,5 +238,5 @@ `stack bench`. (NB: If you're attempting to reproduce these benchmarks, note that the-benchmarks for **Interpolation** are commented out by default, due to-that package not being in Stackage.)+benchmarks for **Interpolation** and **interpolatedstring-perl6** are commented+out by default, due to those packages not being in latest Stackage.)
bench/Bench.hs view
@@ -14,7 +14,7 @@ import "formatting" Formatting ( (%) ) import qualified "formatting" Formatting as F import qualified "formatting" Formatting.ShortFormatters as F-import "interpolatedstring-perl6" Text.InterpolatedString.Perl6 as P+-- import "interpolatedstring-perl6" Text.InterpolatedString.Perl6 as P import qualified "neat-interpolation" NeatInterpolation as NI import Test.QuickCheck@@ -35,8 +35,8 @@ -- stringN :: String -> String -- stringN s = [str|A fine day to die, $s$.|] -stringP :: String -> String-stringP str = [qc|A fine day to die, {str}.|]+-- stringP :: String -> String+-- stringP str = [qc|A fine day to die, {str}.|] -------------------------------------------------------------------------------- -- Interpolating Text@@ -54,8 +54,8 @@ -- textN :: T.Text -> T.Text -- textN t = [str|A fine day to die, $t$.|] -textP :: T.Text -> T.Text-textP t = [qc|A fine day to die, {t}.|]+-- textP :: T.Text -> T.Text+-- textP t = [qc|A fine day to die, {t}.|] textNI :: T.Text -> T.Text textNI t = [NI.text|A fine day to die, $t.|]@@ -73,8 +73,8 @@ -- byteStringN :: B.ByteString -> B.ByteString -- byteStringN b = [str|A fine day to die, $b$.|] -byteStringP :: B.ByteString -> B.ByteString-byteStringP b = [qc|A fine day to die, {b}.|]+-- byteStringP :: B.ByteString -> B.ByteString+-- byteStringP b = [qc|A fine day to die, {b}.|] -------------------------------------------------------------------------------- -- Multiple String interpolations@@ -93,8 +93,8 @@ -- multiStringN :: (Int, String, Bool) -> String -- multiStringN (x, y, z) = [str| foo $:x$ bar $y$ baz $:z$ quux |] -multiStringP :: (Int, String, Bool) -> String-multiStringP (x, y, z) = [qc| foo {x} bar {y} baz {z} quux |]+-- multiStringP :: (Int, String, Bool) -> String+-- multiStringP (x, y, z) = [qc| foo {x} bar {y} baz {z} quux |] -------------------------------------------------------------------------------- -- Multiple Text interpolations@@ -113,8 +113,8 @@ -- multiTextN :: (Int, T.Text, Bool) -> T.Text -- multiTextN (x, y, z) = [str| foo $:x$ bar $y$ baz $:z$ quux |] -multiTextP :: (Int, T.Text, Bool) -> T.Text-multiTextP (x, y, z) = [qc| foo {x} bar {y} baz {z} quux |]+-- multiTextP :: (Int, T.Text, Bool) -> T.Text+-- multiTextP (x, y, z) = [qc| foo {x} bar {y} baz {z} quux |] multiTextNI :: (Int, T.Text, Bool) -> T.Text multiTextNI (x, y, z) =@@ -135,8 +135,8 @@ -- multiByteStringN :: (Int, B.ByteString, Bool) -> B.ByteString -- multiByteStringN (x, y, z) = [str| foo $:x$ bar $y$ baz $:z$ quux |] -multiByteStringP :: (Int, B.ByteString, Bool) -> B.ByteString-multiByteStringP (x, y, z) = [qc| foo {x} bar {y} baz {z} quux |]+-- multiByteStringP :: (Int, B.ByteString, Bool) -> B.ByteString+-- multiByteStringP (x, y, z) = [qc| foo {x} bar {y} baz {z} quux |] main :: IO () main = defaultMain $@@ -145,14 +145,14 @@ , bench "interpolate" $ nf stringI "William" , bench "formatting" $ nf stringF "William" -- , bench "Interpolation" $ nf stringN "William"- , bench "interpolatedstring-perl6" $ nf stringP "William"+ -- , bench "interpolatedstring-perl6" $ nf stringP "William" ] , bgroup "Small Text Bench" $ [ bench "string-interpolate" $ nf textSI "William" , bench "interpolate" $ nf textI "William" , bench "formatting" $ nf textF "William" -- , bench "Interpolation" $ nf textN "William"- , bench "interpolatedstring-perl6" $ nf textP "William"+ -- , bench "interpolatedstring-perl6" $ nf textP "William" , bench "neat-interpolation" $ nf textNI "William" ] , bgroup "Small ByteString Bench" $@@ -160,21 +160,21 @@ , bench "interpolate" $ nf byteStringI "William" -- "formatting" doesn't support ByteStrings. -- , bench "Interpolation" $ nf byteStringN "William"- , bench "interpolatedstring-perl6" $ nf byteStringP "William"+ -- , bench "interpolatedstring-perl6" $ nf byteStringP "William" ] , bgroup "Multiple Interpolations String Bench" $ [ bench "string-interpolate" $ nf multiStringSI (42, "CATALLAXY", True) , bench "interpolate" $ nf multiStringI (42, "CATALLAXY", True) , bench "formatting" $ nf multiStringF (42, "CATALLAXY", True) -- , bench "Interpolation" $ nf multiStringN (42, "CATALLAXY", True)- , bench "interpolatedstring-perl6" $ nf multiStringP (42, "CATALLAXY", True)+ -- , bench "interpolatedstring-perl6" $ nf multiStringP (42, "CATALLAXY", True) ] , bgroup "Multiple Interpolations Text Bench" $ [ bench "string-interpolate" $ nf multiTextSI (42, "CATALLAXY", True) , bench "interpolate" $ nf multiTextI (42, "CATALLAXY", True) , bench "formatting" $ nf multiTextF (42, "CATALLAXY", True) -- , bench "Interpolation" $ nf multiTextN (42, "CATALLAXY", True)- , bench "interpolatedstring-perl6" $ nf multiTextP (42, "CATALLAXY", True)+ -- , bench "interpolatedstring-perl6" $ nf multiTextP (42, "CATALLAXY", True) , bench "neat-interpolation" $ nf multiTextNI (42, "CATALLAXY", True) ] , bgroup "Multiple Interpolations ByteString Bench" $@@ -182,14 +182,14 @@ , bench "interpolate" $ nf multiByteStringI (42, "CATALLAXY", True) -- "formatting" doesn't support ByteStrings. -- , bench "Interpolation" $ nf multiByteStringN (42, "CATALLAXY", True)- , bench "interpolatedstring-perl6" $ nf multiByteStringP (42, "CATALLAXY", True)+ -- , bench "interpolatedstring-perl6" $ nf multiByteStringP (42, "CATALLAXY", True) ] , env largeishText $ \ ~t -> bgroup "Largeish Text Bench" $ [ bench "string-interpolate" $ nf textSI t , bench "interpolate" $ nf textI t , bench "formatting" $ nf textF t -- , bench "Interpolation" $ nf textN t- , bench "interpolatedstring-perl6" $ nf textP t+ -- , bench "interpolatedstring-perl6" $ nf textP t , bench "neat-interpolation" $ nf textNI t ] , env largeishByteString $ \ ~bs -> bgroup "Largeish ByteString Bench" $@@ -197,7 +197,7 @@ , bench "interpolate" $ nf byteStringI bs -- "formatting" doesn't support ByteStrings. -- , bench "Interpolation" $ nf byteStringN bs- , bench "interpolatedstring-perl6" $ nf byteStringP bs+ -- , bench "interpolatedstring-perl6" $ nf byteStringP bs ] ]
src/lib/Data/String/Interpolate/Conversion.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE KindSignatures #-}@@ -13,9 +14,9 @@ ) where -import Data.Int ( Int64 ) import Data.Char ( isSpace )-import Data.Monoid ( (<>) )+import Data.Int ( Int64 )+import Data.Kind ( Type ) import Data.Proxy import Data.String ( IsString, fromString ) import Data.Text.Conversions@@ -32,7 +33,12 @@ import "base" Control.Category ( (>>>) ) -import "base" Text.Show ( ShowS, showString, showChar )+-- Remove some imports above GHC 8.8.X+#if MIN_VERSION_base(4,13,0)+#else+import "base" Data.Monoid ( (<>) )+import "base" Text.Show ( ShowS, showChar, showString )+#endif -- | -- We wrap the builders in B so that we can add a phantom type parameter.@@ -53,7 +59,7 @@ -- | Something that can be interpolated into. class IsCustomSink dst ~ flag => InterpSink (flag :: Bool) dst where- type Builder flag dst :: *+ type Builder flag dst :: Type -- | Meant to be used only for verbatim parts of the interpolation. ofString :: Proxy flag -> String -> B dst (Builder flag dst)@@ -267,7 +273,7 @@ -- | For storing state while we fold over the ByteString. data BSChomper = BSChomper- { bscNumWS :: !Int64+ { bscNumWS :: !Int64 , bscBuilder :: !(Maybe LB.Builder) -- ^ We use Maybe here to know if we've processed -- non-whitespace characters yet. }@@ -284,7 +290,7 @@ finalizeBSC :: BSChomper -> LB.ByteString finalizeBSC bsc = case bscBuilder bsc of- Nothing -> mempty+ Nothing -> mempty Just builder -> LB.toLazyByteString builder instance {-# OVERLAPS #-} SpaceChompable B.ByteString where
string-interpolate.cabal view
@@ -1,85 +1,87 @@ cabal-version: 1.18-name: string-interpolate-version: 0.2.0.2-license: BSD3-license-file: LICENSE-copyright: 2019-2020 William Yao-maintainer: williamyaoh@gmail.com-author: William Yao-homepage: https://gitlab.com/williamyaoh/string-interpolate/blob/master/README.md-bug-reports: https://gitlab.com/williamyaoh/string-interpolate/issues-synopsis: Haskell string/text/bytestring interpolation that just works-description:- Unicode-aware string interpolation that handles all textual types.- .- See the README at <https://gitlab.com/williamyaoh/string-interpolate/blob/master/README.md> for more info.-category: Data, Text-build-type: Simple-extra-doc-files: README.md- CHANGELOG.md +name: string-interpolate+version: 0.2.0.3+synopsis: Haskell string/text/bytestring interpolation that just works+description: Unicode-aware string interpolation that handles all textual types.+ .+ See the README at <https://gitlab.com/williamyaoh/string-interpolate/blob/master/README.md> for more info.+category: Data, Text+homepage: https://gitlab.com/williamyaoh/string-interpolate/blob/master/README.md+bug-reports: https://gitlab.com/williamyaoh/string-interpolate/issues+author: William Yao+maintainer: williamyaoh@gmail.com+copyright: 2019-2020 William Yao+license: BSD3+license-file: LICENSE+build-type: Simple+extra-doc-files:+ README.md+ CHANGELOG.md+ source-repository head- type: git- location: https://www.gitlab.com/williamyaoh/string-interpolate.git+ type: git+ location: https://www.gitlab.com/williamyaoh/string-interpolate.git library exposed-modules: Data.String.Interpolate Data.String.Interpolate.Conversion- hs-source-dirs: src/lib other-modules: Data.String.Interpolate.Parse Paths_string_interpolate- default-language: Haskell2010+ hs-source-dirs:+ src/lib ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances -fno-warn-name-shadowing build-depends:- base ==4.*,- bytestring >=0.10.8.2 && <0.11,- haskell-src-exts >=1.21.1 && <1.22,- haskell-src-meta >=0.8.3 && <0.9,- template-haskell >=2.14.0.0 && <2.15,- text >=1.2.3.1 && <1.3,- text-conversions >=0.3.0 && <0.4,- utf8-string >=1.0.1.1 && <1.1+ base ==4.*+ , bytestring <0.11+ , text <1.3+ , haskell-src-exts <1.24+ , haskell-src-meta <0.9+ , template-haskell <2.16+ , text-conversions <0.4+ , utf8-string <1.1+ default-language: Haskell2010 test-suite string-interpolate-test type: exitcode-stdio-1.0 main-is: Spec.hs- hs-source-dirs: test other-modules: Paths_string_interpolate- default-language: Haskell2010+ hs-source-dirs: test ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends:- QuickCheck >=2.13.2 && <2.14,- base ==4.*,- bytestring >=0.10.8.2 && <0.11,- hspec >=2.7.1 && <2.8,- quickcheck-instances >=0.3.22 && <0.4,- quickcheck-text >=0.1.2.1 && <0.2,- quickcheck-unicode >=1.0.1.0 && <1.1,- random-shuffle >=0.0.4 && <0.1,- string-interpolate -any,- text >=1.2.3.1 && <1.3,- unordered-containers >=0.2.10.0 && <0.3+ base ==4.*+ , string-interpolate -any+ , QuickCheck <2.14+ , bytestring <0.11+ , text <1.3+ , hspec <2.8+ , quickcheck-instances <0.4+ , quickcheck-text <0.2+ , quickcheck-unicode <1.1+ , random-shuffle <0.1+ , unordered-containers <0.3+ default-language: Haskell2010 benchmark string-interpolate-bench type: exitcode-stdio-1.0 main-is: Bench.hs- hs-source-dirs: bench other-modules: Paths_string_interpolate- default-language: Haskell2010+ hs-source-dirs: bench build-depends:- QuickCheck >=2.13.2 && <2.14,- base ==4.*,- bytestring >=0.10.8.2 && <0.11,- criterion >=1.5.6.1 && <1.6,- formatting >=6.3.7 && <6.4,- interpolate >=0.2.0 && <0.3,- interpolatedstring-perl6 >=1.0.2 && <1.1,- neat-interpolation >=0.3.2.6 && <0.4,- string-interpolate -any,- text >=1.2.3.1 && <1.3+ base ==4.*+ , string-interpolate -any+ , QuickCheck <2.14+ , bytestring <0.11+ , text <1.3+ , criterion <1.6+ , formatting <6.4+ , interpolate <0.3+ -- , interpolatedstring-perl6 <1.1+ , neat-interpolation <0.4+ default-language: Haskell2010