packages feed

text-show 3.2.1 → 3.2.2

raw patch · 3 files changed

+141/−2 lines, 3 filesdep +criteriondep +deepseqdep ~QuickCheckdep ~basedep ~base-compat

Dependencies added: criterion, deepseq

Dependency ranges changed: QuickCheck, base, base-compat, generic-deriving, tagged, text-show

Files

CHANGELOG.md view
@@ -1,3 +1,6 @@+### 3.2.2+* Added benchmarks+ ### 3.2.1 * Fixed compilation on GHC 8.0 
+ benchmarks/Bench.hs view
@@ -0,0 +1,96 @@+{-# LANGUAGE DeriveGeneric       #-}+{-# LANGUAGE RankNTypes          #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell     #-}+{-|+Module:      Bench+Copyright:   (C) 2014-2016 Ryan Scott+License:     BSD-style (see the file LICENSE)+Maintainer:  Ryan Scott+Stability:   Provisional+Portability: GHC++Benchmarks for @text-show@.+-}+module Main (main) where++import Control.DeepSeq (NFData)++import Criterion.Main (Benchmark, bench, bgroup, defaultMain, nf)++import Data.List (foldl')++import GHC.Generics (Generic)++import TextShow (TextShow(..))+import TextShow.Generic (genericShowbPrec)+import TextShow.TH (deriveTextShow)++main :: IO ()+main = defaultMain+    [ sampleGroup "String Show"          BTSLeaf    BTSBranch    BTSEmpty    show+    , sampleGroup "Text Show (TH)"       BTTSTHLeaf BTTSTHBranch BTTSTHEmpty showtl+    , sampleGroup "Text Show (generics)" BTTSGLeaf  BTTSGBranch  BTTSGEmpty  showtl+    ]++sampleGroup :: forall a b. NFData b+            => String -> (Int -> a) -> (a -> a -> a) -> a -> (a -> b) -> Benchmark+sampleGroup title leaf branch empty showFun =+    bgroup title+        [ bench "Small sample"  $ nf smallSample  pile+        , bench "Medium sample" $ nf mediumSample pile+        , bench "Large sample"  $ nf largeSample  pile+        ]+  where+    pile :: (Int -> a, a -> a -> a, a, a -> b)+    pile = (leaf, branch, empty, showFun)++type Sample = forall a b.+    ( Int -> a+    , a -> a -> a+    , a+    , a -> b+    ) -> b++smallSample :: Sample+smallSample (leaf, branch, _, showFun) =+    showFun $+        (leaf 12345 `branch` leaf 1234) `branch`+        leaf 123456 `branch`+        (leaf 1234567 `branch` leaf 123456)+{-# NOINLINE smallSample #-}++mediumSample :: Sample+mediumSample (leaf, branch, empty, showFun) =+    showFun . foldl' branch empty . replicate 1000 $+        (leaf 12345 `branch` leaf 1234) `branch`+        leaf 123456 `branch`+        (leaf 1234567 `branch` leaf 123456)+{-# NOINLINE mediumSample #-}++largeSample :: Sample+largeSample (leaf, branch, empty, showFun) =+    showFun . foldl' branch empty . replicate 100000 $+        (leaf 12345 `branch` leaf 1234) `branch`+        leaf 123456 `branch`+        (leaf 1234567 `branch` leaf 123456)+{-# NOINLINE largeSample #-}++data BinTreeShow a = BTSEmpty+                   | BTSLeaf a+                   | BTSBranch (BinTreeShow a) (BinTreeShow a)+  deriving Show++data BinTreeTextShowTH a = BTTSTHEmpty+                         | BTTSTHLeaf a+                         | BTTSTHBranch (BinTreeTextShowTH a)+                                        (BinTreeTextShowTH a)+data BinTreeTextShowGenerics a = BTTSGEmpty+                               | BTTSGLeaf a+                               | BTTSGBranch (BinTreeTextShowGenerics a)+                                             (BinTreeTextShowGenerics a)+  deriving Generic+instance TextShow a => TextShow (BinTreeTextShowGenerics a) where+    showbPrec = genericShowbPrec++$(deriveTextShow ''BinTreeTextShowTH)
text-show.cabal view
@@ -1,5 +1,5 @@ name:                text-show-version:             3.2.1+version:             3.2.2 synopsis:            Efficient conversion of values into Text description:         @text-show@ offers a replacement for the @Show@ typeclass intended                      for use with @Text@ instead of @String@s. This package was created@@ -355,7 +355,7 @@   if impl(ghc >= 8.0)     build-depends:     ghc-boot   if !flag(developer)-    build-depends:     text-show            == 3.2.1+    build-depends:     text-show            == 3.2.2    hs-source-dirs:      tests   if flag(developer)@@ -366,4 +366,44 @@   include-dirs:        include   includes:            generic.h                      , overlap.h+                     , utils.h++benchmark bench+  -- This SHOULD build with 7.4, but criterion goofed:+  -- https://github.com/bos/criterion/pull/99+  if impl(ghc < 7.6)+    buildable:         False++  type:                exitcode-stdio-1.0+  main-is:             Bench.hs+  build-depends:       array               >= 0.3    && < 0.6+                     , base                >= 4.5    && < 5+                     , base-compat         >= 0.8.1  && < 1+                     , bifunctors          >= 5.1    && < 6+                     , bytestring          >= 0.9    && < 0.11+                     , bytestring-builder+                     , containers          >= 0.1    && < 0.6+                     , criterion           >= 1      && < 2+                     , deepseq             >= 1.3    && < 2+                     , generic-deriving    >= 1.9    && < 2+                     , ghc-prim+                     , integer-gmp+                     , nats                >= 0.1    && < 2+                     , semigroups          >= 0.17   && < 1+                     , tagged              >= 0.4.4  && < 1+                     , text                >= 0.11.1 && < 1.3+                     , template-haskell    >= 2.5    && < 2.12+                     , th-lift             >= 0.7.6  && < 1+                     , transformers        >= 0.2.1  && < 0.6+                     , transformers-compat >= 0.5    && < 1+                     , void                >= 0.5    && < 1+  if flag(developer)+    hs-source-dirs:    src+  else+    build-depends:     text-show == 3.2.2+  hs-source-dirs:      benchmarks+  default-language:    Haskell2010+  ghc-options:         -Wall+  include-dirs:        include+  includes:            inline.h                      , utils.h