on master help sign in
separate inspection testing build from benchmark build

Sometimes we may want to just build benchmarks without doing inspection testing, for example GHC head version cannot build inspection-testing package, but we still want to run benchmarks.

commitf5614c725d1b14ca90e8a502d0e7aaa0e311e813 authorHarendra Kumar <harendra.kumar@gmail.com> dateTue 27 Aug 2019, 21:02 (7 years ago) parent7c9c1c4
5 files changed+204−150
src/Streamly/Benchmark/FileIO/Array.hs+35−18 src/Streamly/Benchmark/FileIO/Stream.hs+123−81 src/Streamly/Benchmark/Inspection.hs−29 src/Streamly/Benchmark/Prelude.hs+34−16 streamly.cabal+12−6
src/Streamly/Benchmark/FileIO/Array.hs+35−18
@@ -7,9 +7,12 @@
77-- Stability : experimental
88-- Portability : GHC
99
10−{-# LANGUAGE TemplateHaskell #-}
10+{-# LANGUAGE CPP #-}
1111
12+#ifdef INSPECTION
13+{-# LANGUAGE TemplateHaskell #-}
1214{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
15+#endif
1316
1417module Streamly.Benchmark.FileIO.Array
1518 (
@@ -28,15 +31,15 @@ import Data.Word (Word8)
2831import System.IO (Handle)
2932import Prelude hiding (last)
3033
31−import Streamly.Benchmark.Inspection (hinspect)
32−import Streamly.Streams.StreamD.Type (Step(..))
33−
3434import qualified Streamly.FileSystem.Handle as FH
3535import qualified Streamly.Memory.Array as A
3636import qualified Streamly.Prelude as S
3737import qualified Streamly.Internal as Internal
3838
39+#ifdef INSPECTION
40+import Streamly.Streams.StreamD.Type (Step(..))
3941import Test.Inspection
42+#endif
4043
4144-- | Get the last byte from a file bytestream.
4245{-# INLINE last #-}
@@ -48,8 +51,10 @@ last inh = do
4851 Nothing -> Nothing
4952 Just arr -> A.readIndex arr (A.length arr - 1)
5053
51−hinspect $ hasNoTypeClasses 'last
52−hinspect $ 'last `hasNoType` ''Step
54+#ifdef INSPECTION
55+inspect $ hasNoTypeClasses 'last
56+inspect $ 'last `hasNoType` ''Step
57+#endif
5358
5459-- | Count the number of bytes in a file.
5560{-# INLINE countBytes #-}
@@ -58,16 +63,20 @@ countBytes inh =
5863 let s = FH.readArrays inh
5964 in S.sum (S.map A.length s)
6065
61−hinspect $ hasNoTypeClasses 'countBytes
62−hinspect $ 'countBytes `hasNoType` ''Step
66+#ifdef INSPECTION
67+inspect $ hasNoTypeClasses 'countBytes
68+inspect $ 'countBytes `hasNoType` ''Step
69+#endif
6370
6471-- | Count the number of lines in a file.
6572{-# INLINE countLines #-}
6673countLines :: Handle -> IO Int
6774countLines = S.length . A.splitOn 10 . FH.readArrays
6875
69−hinspect $ hasNoTypeClasses 'countLines
70−hinspect $ 'countLines `hasNoType` ''Step
76+#ifdef INSPECTION
77+inspect $ hasNoTypeClasses 'countLines
78+inspect $ 'countLines `hasNoType` ''Step
79+#endif
7180
7281-- | Sum the bytes in a file.
7382{-# INLINE sumBytes #-}
@@ -77,8 +86,10 @@ sumBytes inh = do
7786 let s = FH.readArrays inh
7887 S.foldl' (\acc arr -> acc + foldlArr' (+) 0 arr) 0 s
7988
80−hinspect $ hasNoTypeClasses 'sumBytes
81−hinspect $ 'sumBytes `hasNoType` ''Step
89+#ifdef INSPECTION
90+inspect $ hasNoTypeClasses 'sumBytes
91+inspect $ 'sumBytes `hasNoType` ''Step
92+#endif
8293
8394-- | Send the file contents to /dev/null
8495{-# INLINE cat #-}
@@ -86,8 +97,10 @@ cat :: Handle -> Handle -> IO ()
8697cat devNull inh =
8798 S.runFold (FH.writeArrays devNull) $ FH.readArraysOf (256*1024) inh
8899
89−hinspect $ hasNoTypeClasses 'cat
90−hinspect $ 'cat `hasNoType` ''Step
100+#ifdef INSPECTION
101+inspect $ hasNoTypeClasses 'cat
102+inspect $ 'cat `hasNoType` ''Step
103+#endif
91104
92105-- | Copy file
93106{-# INLINE copy #-}
@@ -96,8 +109,10 @@ copy inh outh =
96109 let s = FH.readArrays inh
97110 in S.runFold (FH.writeArrays outh) s
98111
99−hinspect $ hasNoTypeClasses 'copy
100−hinspect $ 'copy `hasNoType` ''Step
112+#ifdef INSPECTION
113+inspect $ hasNoTypeClasses 'copy
114+inspect $ 'copy `hasNoType` ''Step
115+#endif
101116
102117-- | Lines and unlines
103118{-# INLINE linesUnlinesCopy #-}
@@ -108,5 +123,7 @@ linesUnlinesCopy inh outh =
108123 $ A.splitOn 10
109124 $ FH.readArraysOf (1024*1024) inh
110125
111−-- hinspect $ hasNoTypeClasses 'linesUnlinesCopy
112−-- hinspect $ 'linesUnlinesCopy `hasNoType` ''Step
126+#ifdef INSPECTION
127+-- inspect $ hasNoTypeClasses 'linesUnlinesCopy
128+-- inspect $ 'linesUnlinesCopy `hasNoType` ''Step
129+#endif
src/Streamly/Benchmark/FileIO/Stream.hs+123−81
@@ -7,9 +7,12 @@
77-- Stability : experimental
88-- Portability : GHC
99
10+{-# LANGUAGE CPP #-}
11+#ifdef INSPECTION
1012{-# LANGUAGE TemplateHaskell #-}
1113
1214{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
15+#endif
1316
1417module Streamly.Benchmark.FileIO.Stream
1518 (
@@ -27,6 +30,7 @@ module Streamly.Benchmark.FileIO.Stream
2730 , copyCodecChar8
2831 , copyCodecUtf8
2932 , chunksOf
33+ , chunksOfD
3034 , splitOn
3135 , splitOnSuffix
3236 , wordsBy
@@ -40,30 +44,32 @@ import Data.Word (Word8)
4044import System.IO (Handle)
4145import Prelude hiding (last, length)
4246
43−import Streamly.Streams.StreamD.Type (Step(..), GroupState)
44−import Streamly.Benchmark.Inspection (hinspect)
45−import qualified Streamly.Memory.Array.Types as AT
46−
4747import qualified Streamly.FileSystem.Handle as FH
4848import qualified Streamly.FileSystem.Handle.Internal as FH
4949import qualified Streamly.Memory.Array as A
50+import qualified Streamly.Memory.Array.Types as AT
5051import qualified Streamly.Prelude.Internal as S
5152import qualified Streamly.Fold as FL
5253import qualified Streamly.Data.String as SS
5354import qualified Streamly.Internal as Internal
5455import qualified Streamly.Streams.StreamD as D
5556
57+#ifdef INSPECTION
58+import Streamly.Streams.StreamD.Type (Step(..), GroupState)
5659import Test.Inspection
60+#endif
5761
5862-- | Get the last byte from a file bytestream.
5963{-# INLINE last #-}
6064last :: Handle -> IO (Maybe Word8)
6165last = S.last . FH.read
6266
63−hinspect $ hasNoTypeClasses 'last
64−hinspect $ 'last `hasNoType` ''Step
65−hinspect $ 'last `hasNoType` ''AT.FlattenState
66−hinspect $ 'last `hasNoType` ''D.ConcatMapUState
67+#ifdef INSPECTION
68+inspect $ hasNoTypeClasses 'last
69+inspect $ 'last `hasNoType` ''Step
70+inspect $ 'last `hasNoType` ''AT.FlattenState
71+inspect $ 'last `hasNoType` ''D.ConcatMapUState
72+#endif
6773
6874-- assert that flattenArrays constructors are not present
6975-- | Count the number of bytes in a file.
@@ -71,10 +77,12 @@ hinspect $ 'last `hasNoType` ''D.ConcatMapUState
7177countBytes :: Handle -> IO Int
7278countBytes = S.length . FH.read
7379
74−hinspect $ hasNoTypeClasses 'countBytes
75−hinspect $ 'countBytes `hasNoType` ''Step
76−hinspect $ 'countBytes `hasNoType` ''AT.FlattenState
77−hinspect $ 'countBytes `hasNoType` ''D.ConcatMapUState
80+#ifdef INSPECTION
81+inspect $ hasNoTypeClasses 'countBytes
82+inspect $ 'countBytes `hasNoType` ''Step
83+inspect $ 'countBytes `hasNoType` ''AT.FlattenState
84+inspect $ 'countBytes `hasNoType` ''D.ConcatMapUState
85+#endif
7886
7987-- | Count the number of lines in a file.
8088{-# INLINE countLines #-}
@@ -85,10 +93,12 @@ countLines =
8593 . SS.decodeChar8
8694 . FH.read
8795
88−hinspect $ hasNoTypeClasses 'countLines
89−hinspect $ 'countLines `hasNoType` ''Step
90−hinspect $ 'countLines `hasNoType` ''AT.FlattenState
91−hinspect $ 'countLines `hasNoType` ''D.ConcatMapUState
96+#ifdef INSPECTION
97+inspect $ hasNoTypeClasses 'countLines
98+inspect $ 'countLines `hasNoType` ''Step
99+inspect $ 'countLines `hasNoType` ''AT.FlattenState
100+inspect $ 'countLines `hasNoType` ''D.ConcatMapUState
101+#endif
92102
93103-- | Count the number of lines in a file.
94104{-# INLINE countLinesU #-}
@@ -99,49 +109,59 @@ countLinesU inh =
99109 $ SS.decodeChar8
100110 $ Internal.concatMapU Internal.readU (FH.readArrays inh)
101111
102−hinspect $ hasNoTypeClasses 'countLinesU
103−hinspect $ 'countLinesU `hasNoType` ''Step
104−hinspect $ 'countLinesU `hasNoType` ''D.ConcatMapUState
112+#ifdef INSPECTION
113+inspect $ hasNoTypeClasses 'countLinesU
114+inspect $ 'countLinesU `hasNoType` ''Step
115+inspect $ 'countLinesU `hasNoType` ''D.ConcatMapUState
116+#endif
105117
106118-- | Sum the bytes in a file.
107119{-# INLINE sumBytes #-}
108120sumBytes :: Handle -> IO Word8
109121sumBytes = S.sum . FH.read
110122
111−hinspect $ hasNoTypeClasses 'sumBytes
112−hinspect $ 'sumBytes `hasNoType` ''Step
113−hinspect $ 'sumBytes `hasNoType` ''AT.FlattenState
114−hinspect $ 'sumBytes `hasNoType` ''D.ConcatMapUState
123+#ifdef INSPECTION
124+inspect $ hasNoTypeClasses 'sumBytes
125+inspect $ 'sumBytes `hasNoType` ''Step
126+inspect $ 'sumBytes `hasNoType` ''AT.FlattenState
127+inspect $ 'sumBytes `hasNoType` ''D.ConcatMapUState
128+#endif
115129
116130-- | Send the file contents to /dev/null
117131{-# INLINE cat #-}
118132cat :: Handle -> Handle -> IO ()
119133cat devNull inh = S.runFold (FH.write devNull) $ FH.read inh
120134
121−hinspect $ hasNoTypeClasses 'cat
122−hinspect $ 'cat `hasNoType` ''Step
123−hinspect $ 'cat `hasNoType` ''AT.FlattenState
124−hinspect $ 'cat `hasNoType` ''D.ConcatMapUState
135+#ifdef INSPECTION
136+inspect $ hasNoTypeClasses 'cat
137+inspect $ 'cat `hasNoType` ''Step
138+inspect $ 'cat `hasNoType` ''AT.FlattenState
139+inspect $ 'cat `hasNoType` ''D.ConcatMapUState
140+#endif
125141
126142-- | Send the file contents to /dev/null
127143{-# INLINE catStreamWrite #-}
128144catStreamWrite :: Handle -> Handle -> IO ()
129145catStreamWrite devNull inh = FH.writeS devNull $ FH.read inh
130146
131−hinspect $ hasNoTypeClasses 'catStreamWrite
132−hinspect $ 'catStreamWrite `hasNoType` ''Step
133−hinspect $ 'catStreamWrite `hasNoType` ''AT.FlattenState
134−hinspect $ 'catStreamWrite `hasNoType` ''D.ConcatMapUState
147+#ifdef INSPECTION
148+inspect $ hasNoTypeClasses 'catStreamWrite
149+inspect $ 'catStreamWrite `hasNoType` ''Step
150+inspect $ 'catStreamWrite `hasNoType` ''AT.FlattenState
151+inspect $ 'catStreamWrite `hasNoType` ''D.ConcatMapUState
152+#endif
135153
136154-- | Copy file
137155{-# INLINE copy #-}
138156copy :: Handle -> Handle -> IO ()
139157copy inh outh = S.runFold (FH.write outh) (FH.read inh)
140158
141−hinspect $ hasNoTypeClasses 'copy
142−hinspect $ 'copy `hasNoType` ''Step
143−hinspect $ 'copy `hasNoType` ''AT.FlattenState
144−hinspect $ 'copy `hasNoType` ''D.ConcatMapUState
159+#ifdef INSPECTION
160+inspect $ hasNoTypeClasses 'copy
161+inspect $ 'copy `hasNoType` ''Step
162+inspect $ 'copy `hasNoType` ''AT.FlattenState
163+inspect $ 'copy `hasNoType` ''D.ConcatMapUState
164+#endif
145165
146166-- | Copy file
147167{-# INLINE copyCodecChar8 #-}
@@ -152,10 +172,12 @@ copyCodecChar8 inh outh =
152172 $ SS.decodeChar8
153173 $ FH.read inh
154174
155−hinspect $ hasNoTypeClasses 'copyCodecChar8
156−hinspect $ 'copyCodecChar8 `hasNoType` ''Step
157−hinspect $ 'copyCodecChar8 `hasNoType` ''AT.FlattenState
158−hinspect $ 'copyCodecChar8 `hasNoType` ''D.ConcatMapUState
175+#ifdef INSPECTION
176+inspect $ hasNoTypeClasses 'copyCodecChar8
177+inspect $ 'copyCodecChar8 `hasNoType` ''Step
178+inspect $ 'copyCodecChar8 `hasNoType` ''AT.FlattenState
179+inspect $ 'copyCodecChar8 `hasNoType` ''D.ConcatMapUState
180+#endif
159181
160182-- | Copy file
161183{-# INLINE copyCodecUtf8 #-}
@@ -166,10 +188,12 @@ copyCodecUtf8 inh outh =
166188 $ SS.decodeUtf8
167189 $ FH.read inh
168190
169−hinspect $ hasNoTypeClasses 'copyCodecUtf8
170−-- hinspect $ 'copyCodecUtf8 `hasNoType` ''Step
171−-- hinspect $ 'copyCodecUtf8 `hasNoType` ''AT.FlattenState
172−-- hinspect $ 'copyCodecUtf8 `hasNoType` ''D.ConcatMapUState
191+#ifdef INSPECTION
192+inspect $ hasNoTypeClasses 'copyCodecUtf8
193+-- inspect $ 'copyCodecUtf8 `hasNoType` ''Step
194+-- inspect $ 'copyCodecUtf8 `hasNoType` ''AT.FlattenState
195+-- inspect $ 'copyCodecUtf8 `hasNoType` ''D.ConcatMapUState
196+#endif
173197
174198-- | Slice in chunks of size n and get the count of chunks.
175199{-# INLINE chunksOf #-}
@@ -178,11 +202,13 @@ chunksOf n inh =
178202 -- writeNUnsafe gives 2.5x boost here over writeN.
179203 S.length $ S.chunksOf n (AT.writeNUnsafe n) (FH.read inh)
180204
181−hinspect $ hasNoTypeClasses 'chunksOf
182−hinspect $ 'chunksOf `hasNoType` ''Step
183−hinspect $ 'chunksOf `hasNoType` ''AT.FlattenState
184−hinspect $ 'chunksOf `hasNoType` ''D.ConcatMapUState
185−hinspect $ 'chunksOf `hasNoType` ''GroupState
205+#ifdef INSPECTION
206+inspect $ hasNoTypeClasses 'chunksOf
207+inspect $ 'chunksOf `hasNoType` ''Step
208+inspect $ 'chunksOf `hasNoType` ''AT.FlattenState
209+inspect $ 'chunksOf `hasNoType` ''D.ConcatMapUState
210+inspect $ 'chunksOf `hasNoType` ''GroupState
211+#endif
186212
187213-- This is to make sure that the concatMap in FH.read, groupsOf and foldlM'
188214-- together can fuse.
@@ -195,11 +221,13 @@ chunksOfD n inh =
195221 $ D.groupsOf n (AT.writeNUnsafe n)
196222 $ D.fromStreamK (FH.read inh)
197223
198−hinspect $ hasNoTypeClasses 'chunksOf
199−hinspect $ 'chunksOf `hasNoType` ''Step
200−hinspect $ 'chunksOfD `hasNoType` ''GroupState
201−hinspect $ 'chunksOfD `hasNoType` ''AT.FlattenState
202−hinspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
224+#ifdef INSPECTION
225+inspect $ hasNoTypeClasses 'chunksOf
226+inspect $ 'chunksOf `hasNoType` ''Step
227+inspect $ 'chunksOfD `hasNoType` ''GroupState
228+inspect $ 'chunksOfD `hasNoType` ''AT.FlattenState
229+inspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
230+#endif
203231
204232-- | Lines and unlines
205233{-# INLINE linesUnlinesCopy #-}
@@ -212,10 +240,12 @@ linesUnlinesCopy inh outh =
212240 $ SS.decodeChar8
213241 $ FH.read inh
214242
215−-- hinspect $ hasNoTypeClasses 'linesUnlinesCopy
216−-- hinspect $ 'linesUnlinesCopy `hasNoType` ''Step
217−-- hinspect $ 'linesUnlinesCopy `hasNoType` ''AT.FlattenState
218−-- hinspect $ 'linesUnlinesCopy `hasNoType` ''D.ConcatMapUState
243+#ifdef INSPECTION
244+-- inspect $ hasNoTypeClasses 'linesUnlinesCopy
245+-- inspect $ 'linesUnlinesCopy `hasNoType` ''Step
246+-- inspect $ 'linesUnlinesCopy `hasNoType` ''AT.FlattenState
247+-- inspect $ 'linesUnlinesCopy `hasNoType` ''D.ConcatMapUState
248+#endif
219249
220250-- | Word, unwords and copy
221251{-# INLINE wordsUnwordsCopy #-}
@@ -228,10 +258,12 @@ wordsUnwordsCopy inh outh =
228258 $ SS.decodeChar8
229259 $ FH.read inh
230260
231−-- hinspect $ hasNoTypeClasses 'wordsUnwordsCopy
232−-- hinspect $ 'wordsUnwordsCopy `hasNoType` ''Step
233−-- hinspect $ 'wordsUnwordsCopy `hasNoType` ''AT.FlattenState
234−-- hinspect $ 'wordsUnwordsCopy `hasNoType` ''D.ConcatMapUState
261+#ifdef INSPECTION
262+-- inspect $ hasNoTypeClasses 'wordsUnwordsCopy
263+-- inspect $ 'wordsUnwordsCopy `hasNoType` ''Step
264+-- inspect $ 'wordsUnwordsCopy `hasNoType` ''AT.FlattenState
265+-- inspect $ 'wordsUnwordsCopy `hasNoType` ''D.ConcatMapUState
266+#endif
235267
236268lf :: Word8
237269lf = fromIntegral (ord '\n')
@@ -267,10 +299,12 @@ splitOn inh =
267299 (S.length $ S.splitOn (== lf) FL.drain
268300 $ FH.read inh) -- >>= print
269301
270−hinspect $ hasNoTypeClasses 'splitOn
271−hinspect $ 'splitOn `hasNoType` ''Step
272−hinspect $ 'splitOn `hasNoType` ''AT.FlattenState
273−hinspect $ 'splitOn `hasNoType` ''D.ConcatMapUState
302+#ifdef INSPECTION
303+inspect $ hasNoTypeClasses 'splitOn
304+inspect $ 'splitOn `hasNoType` ''Step
305+inspect $ 'splitOn `hasNoType` ''AT.FlattenState
306+inspect $ 'splitOn `hasNoType` ''D.ConcatMapUState
307+#endif
274308
275309-- | Split suffix on line feed.
276310{-# INLINE splitOnSuffix #-}
@@ -279,10 +313,12 @@ splitOnSuffix inh =
279313 (S.length $ S.splitOnSuffix (== lf) FL.drain
280314 $ FH.read inh) -- >>= print
281315
282−hinspect $ hasNoTypeClasses 'splitOnSuffix
283−hinspect $ 'splitOnSuffix `hasNoType` ''Step
284−hinspect $ 'splitOnSuffix `hasNoType` ''AT.FlattenState
285−hinspect $ 'splitOnSuffix `hasNoType` ''D.ConcatMapUState
316+#ifdef INSPECTION
317+inspect $ hasNoTypeClasses 'splitOnSuffix
318+inspect $ 'splitOnSuffix `hasNoType` ''Step
319+inspect $ 'splitOnSuffix `hasNoType` ''AT.FlattenState
320+inspect $ 'splitOnSuffix `hasNoType` ''D.ConcatMapUState
321+#endif
286322
287323-- | Words by space
288324{-# INLINE wordsBy #-}
@@ -291,10 +327,12 @@ wordsBy inh =
291327 (S.length $ S.wordsBy isSp FL.drain
292328 $ FH.read inh) -- >>= print
293329
294−hinspect $ hasNoTypeClasses 'wordsBy
295−hinspect $ 'wordsBy `hasNoType` ''Step
296−hinspect $ 'wordsBy `hasNoType` ''AT.FlattenState
297−hinspect $ 'wordsBy `hasNoType` ''D.ConcatMapUState
330+#ifdef INSPECTION
331+inspect $ hasNoTypeClasses 'wordsBy
332+inspect $ 'wordsBy `hasNoType` ''Step
333+inspect $ 'wordsBy `hasNoType` ''AT.FlattenState
334+inspect $ 'wordsBy `hasNoType` ''D.ConcatMapUState
335+#endif
298336
299337-- | Split on a character sequence.
300338{-# INLINE splitOnSeq #-}
@@ -303,10 +341,12 @@ splitOnSeq str inh =
303341 (S.length $ Internal.splitOnSeq (toarr str) FL.drain
304342 $ FH.read inh) -- >>= print
305343
306−hinspect $ hasNoTypeClasses 'splitOnSeq
307−-- hinspect $ 'splitOnSeq `hasNoType` ''Step
308−-- hinspect $ 'splitOnSeq `hasNoType` ''AT.FlattenState
309−-- hinspect $ 'splitOnSeq `hasNoType` ''D.ConcatMapUState
344+#ifdef INSPECTION
345+inspect $ hasNoTypeClasses 'splitOnSeq
346+-- inspect $ 'splitOnSeq `hasNoType` ''Step
347+-- inspect $ 'splitOnSeq `hasNoType` ''AT.FlattenState
348+-- inspect $ 'splitOnSeq `hasNoType` ''D.ConcatMapUState
349+#endif
310350
311351-- | Split on suffix sequence.
312352{-# INLINE splitOnSuffixSeq #-}
@@ -315,7 +355,9 @@ splitOnSuffixSeq str inh =
315355 (S.length $ Internal.splitOnSuffixSeq (toarr str) FL.drain
316356 $ FH.read inh) -- >>= print
317357
318−hinspect $ hasNoTypeClasses 'splitOnSuffixSeq
319−-- hinspect $ 'splitOnSuffixSeq `hasNoType` ''Step
320−-- hinspect $ 'splitOnSuffixSeq `hasNoType` ''AT.FlattenState
321−-- hinspect $ 'splitOnSuffixSeq `hasNoType` ''D.ConcatMapUState
358+#ifdef INSPECTION
359+inspect $ hasNoTypeClasses 'splitOnSuffixSeq
360+-- inspect $ 'splitOnSuffixSeq `hasNoType` ''Step
361+-- inspect $ 'splitOnSuffixSeq `hasNoType` ''AT.FlattenState
362+-- inspect $ 'splitOnSuffixSeq `hasNoType` ''D.ConcatMapUState
363+#endif
src/Streamly/Benchmark/Inspection.hsdeleted−29
@@ -1,29 +0,0 @@
1−-- |
2−-- Module : Streamly.Benchmark.Inspection
3−-- Copyright : (c) 2019 Composewell Technologies
4−--
5−-- License : BSD3
6−-- Maintainer : harendra.kumar@gmail.com
7−-- Stability : experimental
8−-- Portability : GHC
9−
10−{-# LANGUAGE CPP #-}
11−{-# LANGUAGE TemplateHaskell #-}
12−
13−{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
14−
15−module Streamly.Benchmark.Inspection
16− (
17− hinspect
18− )
19−where
20−
21−import Test.Inspection
22−import Language.Haskell.TH (Q, Dec)
23−
24−hinspect :: Obligation -> Q [Dec]
25−#ifdef __HADDOCK_VERSION__
26−hinspect _ = return []
27−#else
28−hinspect = inspect
29−#endif
src/Streamly/Benchmark/Prelude.hs+34−16
@@ -10,9 +10,11 @@
1010{-# LANGUAGE ScopedTypeVariables #-}
1111{-# LANGUAGE DeriveAnyClass #-}
1212{-# LANGUAGE DeriveGeneric #-}
13−{-# LANGUAGE TemplateHaskell #-}
1413
14+#ifdef INSPECTION
15+{-# LANGUAGE TemplateHaskell #-}
1516{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
17+#endif
1618
1719module Streamly.Benchmark.Prelude where
1820
@@ -31,10 +33,10 @@ import qualified Prelude as P
3133import qualified Data.Foldable as F
3234import qualified GHC.Exts as GHC
3335
34−import Test.Inspection
35−
36+#ifdef INSPECTION
3637import Streamly.Streams.StreamD.Type (Step(..))
37−import Streamly.Benchmark.Inspection (hinspect)
38+import Test.Inspection
39+#endif
3840
3941import qualified Streamly as S hiding (foldMapWith, runStream)
4042import qualified Streamly.Prelude as S
@@ -514,8 +516,10 @@ zipM' src = do
514516zipM :: Int -> IO ()
515517zipM n = zipM' $ source n
516518
517−hinspect $ hasNoTypeClasses 'zipM
518−-- hinspect $ 'zipM `hasNoType` ''Step
519+#ifdef INSPECTION
520+inspect $ hasNoTypeClasses 'zipM
521+-- inspect $ 'zipM `hasNoType` ''Step
522+#endif
519523
520524{-# INLINE mergeBy' #-}
521525mergeBy' :: Monad m => Stream m Int -> m ()
@@ -528,8 +532,11 @@ mergeBy' src = do
528532mergeBy :: Int -> IO ()
529533mergeBy n = mergeBy' $ source n
530534
531−hinspect $ hasNoTypeClasses 'mergeBy
532−-- hinspect $ 'mergeBy `hasNoType` ''Step
535+#ifdef INSPECTION
536+inspect $ hasNoTypeClasses 'mergeBy
537+-- inspect $ 'mergeBy `hasNoType` ''Step
538+#endif
539+
533540
534541{-# INLINE isPrefixOf #-}
535542{-# INLINE isSubsequenceOf #-}
@@ -573,15 +580,21 @@ eqBy' src = S.eqBy (==) src src
573580eqBy :: Int -> IO Bool
574581eqBy n = eqBy' (source n)
575582
576−hinspect $ hasNoTypeClasses 'eqBy
577−hinspect $ 'eqBy `hasNoType` ''Step
583+#ifdef INSPECTION
584+inspect $ hasNoTypeClasses 'eqBy
585+inspect $ 'eqBy `hasNoType` ''Step
586+#endif
587+
578588
579589{-# INLINE eqByPure #-}
580590eqByPure :: Int -> Identity Bool
581591eqByPure n = eqBy' (sourceUnfoldr n)
582592
583−hinspect $ hasNoTypeClasses 'eqByPure
584−hinspect $ 'eqByPure `hasNoType` ''Step
593+#ifdef INSPECTION
594+inspect $ hasNoTypeClasses 'eqByPure
595+inspect $ 'eqByPure `hasNoType` ''Step
596+#endif
597+
585598
586599{-# INLINE cmpBy' #-}
587600cmpBy' :: (Monad m, P.Ord a) => Stream m a -> m P.Ordering
@@ -591,15 +604,20 @@ cmpBy' src = S.cmpBy P.compare src src
591604cmpBy :: Int -> IO P.Ordering
592605cmpBy n = cmpBy' (source n)
593606
594−hinspect $ hasNoTypeClasses 'cmpBy
595−hinspect $ 'cmpBy `hasNoType` ''Step
607+#ifdef INSPECTION
608+inspect $ hasNoTypeClasses 'cmpBy
609+inspect $ 'cmpBy `hasNoType` ''Step
610+#endif
611+
596612
597613{-# INLINE cmpByPure #-}
598614cmpByPure :: Int -> Identity P.Ordering
599615cmpByPure n = cmpBy' (sourceUnfoldr n)
600616
601−hinspect $ hasNoTypeClasses 'cmpByPure
602−hinspect $ 'cmpByPure `hasNoType` ''Step
617+#ifdef INSPECTION
618+inspect $ hasNoTypeClasses 'cmpByPure
619+inspect $ 'cmpByPure `hasNoType` ''Step
620+#endif
603621
604622-- The worst case for concatMap, concat a 1 element stream n times.
605623{-# INLINE concatMap #-}
streamly.cabal+12−6
@@ -137,6 +137,11 @@ flag benchmark
137137 manual: True
138138 default: False
139139
140+flag inspection
141+ description: Enable inspection testing
142+ manual: True
143+ default: False
144+
140145flag dev
141146 description: Development build
142147 manual: True
@@ -187,6 +192,9 @@ common compile-options
187192 if flag(dev)
188193 cpp-options: -DDEVBUILD
189194
195+ if flag(inspection)
196+ cpp-options: -DINSPECTION
197+
190198 ghc-options: -Wall
191199
192200 if flag(has-llvm)
@@ -326,8 +334,7 @@ library
326334
327335 if flag(benchmark)
328336 exposed-modules:
329− Streamly.Benchmark.Inspection
330− , Streamly.Benchmark.FileIO.Array
337+ Streamly.Benchmark.FileIO.Array
331338 , Streamly.Benchmark.FileIO.Stream
332339 , Streamly.Benchmark.Prelude
333340
@@ -348,9 +355,9 @@ library
348355 , transformers >= 0.4 && < 0.6
349356 , transformers-base >= 0.4 && < 0.5
350357
351− if flag(benchmark)
352− build-depends: inspection-testing >= 0.4 && < 0.5
353− , template-haskell >= 2.14 && < 2.16
358+ if flag(inspection)
359+ build-depends: template-haskell >= 2.14 && < 2.16
360+ , inspection-testing >= 0.4 && < 0.5
354361
355362 if !impl(ghcjs)
356363 build-depends:
@@ -621,7 +628,6 @@ benchmark fileio
621628 streamly
622629 , base >= 4.8 && < 5
623630 , gauge >= 0.2.4 && < 0.3
624− , inspection-testing >= 0.4 && < 0.5
625631 , typed-process >= 0.2.3 && < 0.3
626632 , deepseq >= 1.4.1 && < 1.5
627633 else