git.iko.soy/typeable/attoparsec
on master help sign in
Fix build with older GHC
commita2f70c89d161318c4a098272f0c20d8b01c607a1 authorBryan O'Sullivan <bos@serpentine.com> dateFri 9 May 2014, 08:37 (12 years ago) parent0c55479
5 files changed+27−17
attoparsec.cabal+1 benchmarks/Benchmarks.hs+1−17 benchmarks/Common.hs+23 benchmarks/HeadersByteString.hs+1 benchmarks/attoparsec-benchmarks.cabal+1
attoparsec.cabal+1
@@ -100,6 +100,7 @@ benchmark benchmarks
100100 ghc-options: -O2 -Wall
101101 main-is: Benchmarks.hs
102102 other-modules:
103+ Common
103104 HeadersByteString
104105 HeadersText
105106 Numbers
benchmarks/Benchmarks.hs+1−17
@@ -1,14 +1,13 @@
11{-# LANGUAGE BangPatterns, CPP #-}
2−{-# OPTIONS_GHC -fno-warn-orphans #-}
32
43import Control.Applicative (many)
5−import Control.DeepSeq (NFData(rnf))
64import Criterion.Main (bench, bgroup, defaultMain, nf)
75import Data.Bits
86import Data.Char (isAlpha)
97import Data.Word (Word32)
108import Data.Word (Word8)
119import Numbers (numbers)
10+import Common (chunksOf)
1211import qualified HeadersByteString
1312import qualified HeadersText
1413import Text.Parsec.Text ()
@@ -25,21 +24,6 @@ import qualified Data.Text as T
2524import qualified Data.Text.Lazy as TL
2625import qualified Text.Parsec as P
2726
28−#if !MIN_VERSION_bytestring(0,10,0)
29−import Data.ByteString.Internal (ByteString(..))
30−instance NFData ByteString where
31− rnf (PS _ _ _) = ()
32−#endif
33−
34−instance NFData P.ParseError where
35− rnf = rnf . show
36−
37−chunksOf :: Int -> [a] -> [[a]]
38−chunksOf k = go
39− where go xs = case splitAt k xs of
40− ([],_) -> []
41− (y, ys) -> y : go ys
42−
4327main :: IO ()
4428main = do
4529 let s = take 1024 . cycle $ ['a'..'z'] ++ ['A'..'Z']
benchmarks/Common.hsnew file+23
@@ -0,0 +1,23 @@
1+{-# LANGUAGE CPP #-}
2+{-# OPTIONS_GHC -fno-warn-orphans #-}
3+
4+module Common (chunksOf) where
5+
6+import Control.DeepSeq (NFData(rnf))
7+import Text.Parsec (ParseError)
8+
9+#if !MIN_VERSION_bytestring(0,10,0)
10+import Data.ByteString.Internal (ByteString(..))
11+
12+instance NFData ByteString where
13+ rnf (PS _ _ _) = ()
14+#endif
15+
16+instance NFData ParseError where
17+ rnf = rnf . show
18+
19+chunksOf :: Int -> [a] -> [[a]]
20+chunksOf k = go
21+ where go xs = case splitAt k xs of
22+ ([],_) -> []
23+ (y, ys) -> y : go ys
benchmarks/HeadersByteString.hs+1
@@ -2,6 +2,7 @@
22{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
33module HeadersByteString (headers) where
44
5+import Common ()
56import Control.Applicative
67import Criterion.Main (bench, bgroup, nf)
78import Criterion.Types (Benchmark)
benchmarks/attoparsec-benchmarks.cabal+1
@@ -9,6 +9,7 @@ build-type: Simple
99executable attoparsec-benchmarks
1010 main-is: Benchmarks.hs
1111 other-modules:
12+ Common
1213 HeadersByteString
1314 HeadersText
1415 Numbers