on master help sign in
Use INLINE instead of INLINABLE in open loop ops
commitfe478a48cc16dcdf01990ae2ec2b6f715caff329 authorHarendra Kumar <harendra@composewell.com> dateWed 26 Jan 2022, 00:20 (5 years ago) parent3dd9c8d
13 files changed+51−51
src/Streamly/Internal/Data/Fold.hs+23−23 src/Streamly/Internal/Data/Fold/Type.hs+7−7 src/Streamly/Internal/Data/Maybe/Strict.hs+3−3 src/Streamly/Internal/Data/Stream/IsStream/Common.hs+2−2 src/Streamly/Internal/Data/Stream/IsStream/Expand.hs+1−1 src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+2−2 src/Streamly/Internal/Data/Stream/IsStream/Type.hs+1−1 src/Streamly/Internal/FileSystem/Dir.hs+1−1 src/Streamly/Internal/FileSystem/FD.hs+1−1 src/Streamly/Internal/FileSystem/File.hs+4−4 src/Streamly/Internal/FileSystem/Handle.hs+1−1 src/Streamly/Internal/Network/Inet/TCP.hs+4−4 src/Streamly/Internal/Network/Socket.hs+1−1
src/Streamly/Internal/Data/Fold.hs+23−23
@@ -478,7 +478,7 @@ postscan (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
478478-- See also: 'Streamly.Prelude.mapM_'
479479--
480480-- @since 0.7.0
481−{-# INLINABLE drainBy #-}
481+{-# INLINE drainBy #-}
482482drainBy :: Monad m => (a -> m b) -> Fold m a ()
483483drainBy f = lmapM f drain
484484
@@ -487,7 +487,7 @@ drainBy f = lmapM f drain
487487-- > last = fmap getLast $ Fold.foldMap (Last . Just)
488488--
489489-- @since 0.7.0
490−{-# INLINABLE last #-}
490+{-# INLINE last #-}
491491last :: Monad m => Fold m a (Maybe a)
492492last = foldl1' (\_ x -> x)
493493
@@ -612,7 +612,7 @@ minimum = foldl1' min
612612-- stream.
613613--
614614-- @since 0.7.0
615−{-# INLINABLE mean #-}
615+{-# INLINE mean #-}
616616mean :: (Monad m, Fractional a) => Fold m a a
617617mean = fmap done $ foldl' step begin
618618
@@ -630,7 +630,7 @@ mean = fmap done $ foldl' step begin
630630-- the input stream.
631631--
632632-- @since 0.7.0
633−{-# INLINABLE variance #-}
633+{-# INLINE variance #-}
634634variance :: (Monad m, Fractional a) => Fold m a a
635635variance = fmap done $ foldl' step begin
636636
@@ -653,7 +653,7 @@ variance = fmap done $ foldl' step begin
653653-- elements in the input stream.
654654--
655655-- @since 0.7.0
656−{-# INLINABLE stdDev #-}
656+{-# INLINE stdDev #-}
657657stdDev :: (Monad m, Floating a) => Fold m a a
658658stdDev = sqrt <$> variance
659659
@@ -669,7 +669,7 @@ stdDev = sqrt <$> variance
669669-- See https://en.wikipedia.org/wiki/Rolling_hash
670670--
671671-- @since 0.8.0
672−{-# INLINABLE rollingHashWithSalt #-}
672+{-# INLINE rollingHashWithSalt #-}
673673rollingHashWithSalt :: (Monad m, Enum a) => Int64 -> Fold m a Int64
674674rollingHashWithSalt = foldl' step
675675
@@ -689,7 +689,7 @@ defaultSalt = -2578643520546668380
689689-- > rollingHash = Fold.rollingHashWithSalt defaultSalt
690690--
691691-- @since 0.8.0
692−{-# INLINABLE rollingHash #-}
692+{-# INLINE rollingHash #-}
693693rollingHash :: (Monad m, Enum a) => Fold m a Int64
694694rollingHash = rollingHashWithSalt defaultSalt
695695
@@ -699,7 +699,7 @@ rollingHash = rollingHashWithSalt defaultSalt
699699-- > rollingHashFirstN = Fold.take n Fold.rollingHash
700700--
701701-- /Pre-release/
702−{-# INLINABLE rollingHashFirstN #-}
702+{-# INLINE rollingHashFirstN #-}
703703rollingHashFirstN :: (Monad m, Enum a) => Int -> Fold m a Int64
704704rollingHashFirstN n = take n rollingHash
705705
@@ -749,7 +749,7 @@ mconcat = sconcat mempty
749749-- Sum {getSum = 55}
750750--
751751-- @since 0.7.0
752−{-# INLINABLE foldMap #-}
752+{-# INLINE foldMap #-}
753753foldMap :: (Monad m, Monoid b
754754#if !MIN_VERSION_base(4,11,0)
755755 , Semigroup b
@@ -767,7 +767,7 @@ foldMap f = lmap f mconcat
767767-- Sum {getSum = 55}
768768--
769769-- @since 0.7.0
770−{-# INLINABLE foldMapM #-}
770+{-# INLINE foldMapM #-}
771771foldMapM :: (Monad m, Monoid b) => (a -> m b) -> Fold m a b
772772foldMapM act = foldlM' step (pure mempty)
773773
@@ -795,7 +795,7 @@ foldMapM act = foldlM' step (pure mempty)
795795-- @since 0.8.0
796796
797797-- xn : ... : x2 : x1 : []
798−{-# INLINABLE toListRev #-}
798+{-# INLINE toListRev #-}
799799toListRev :: Monad m => Fold m a [a]
800800toListRev = foldl' (flip (:)) []
801801
@@ -820,7 +820,7 @@ drainN n = take n drain
820820-- | Like 'index', except with a more general 'Integral' argument
821821--
822822-- /Pre-release/
823−{-# INLINABLE genericIndex #-}
823+{-# INLINE genericIndex #-}
824824genericIndex :: (Integral i, Monad m) => i -> Fold m a (Maybe a)
825825genericIndex i = mkFold step (Partial 0) (const Nothing)
826826
@@ -836,21 +836,21 @@ genericIndex i = mkFold step (Partial 0) (const Nothing)
836836-- See also: 'Streamly.Prelude.!!'
837837--
838838-- @since 0.7.0
839−{-# INLINABLE index #-}
839+{-# INLINE index #-}
840840index :: Monad m => Int -> Fold m a (Maybe a)
841841index = genericIndex
842842
843843-- | Extract the first element of the stream, if any.
844844--
845845-- @since 0.7.0
846−{-# INLINABLE head #-}
846+{-# INLINE head #-}
847847head :: Monad m => Fold m a (Maybe a)
848848head = mkFold_ (const (Done . Just)) (Partial Nothing)
849849
850850-- | Returns the first element that satisfies the given predicate.
851851--
852852-- @since 0.7.0
853−{-# INLINABLE find #-}
853+{-# INLINE find #-}
854854find :: Monad m => (a -> Bool) -> Fold m a (Maybe a)
855855find predicate = mkFold step (Partial ()) (const Nothing)
856856
@@ -867,7 +867,7 @@ find predicate = mkFold step (Partial ()) (const Nothing)
867867-- > lookup = snd <$> Fold.find ((==) . fst)
868868--
869869-- @since 0.7.0
870−{-# INLINABLE lookup #-}
870+{-# INLINE lookup #-}
871871lookup :: (Eq a, Monad m) => a -> Fold m (a,b) (Maybe b)
872872lookup a0 = mkFold step (Partial ()) (const Nothing)
873873
@@ -881,7 +881,7 @@ lookup a0 = mkFold step (Partial ()) (const Nothing)
881881-- | Returns the first index that satisfies the given predicate.
882882--
883883-- @since 0.7.0
884−{-# INLINABLE findIndex #-}
884+{-# INLINE findIndex #-}
885885findIndex :: Monad m => (a -> Bool) -> Fold m a (Maybe Int)
886886findIndex predicate = mkFold step (Partial 0) (const Nothing)
887887
@@ -897,7 +897,7 @@ findIndex predicate = mkFold step (Partial 0) (const Nothing)
897897-- > elemIndex a = Fold.findIndex (== a)
898898--
899899-- @since 0.7.0
900−{-# INLINABLE elemIndex #-}
900+{-# INLINE elemIndex #-}
901901elemIndex :: (Eq a, Monad m) => a -> Fold m a (Maybe Int)
902902elemIndex a = findIndex (a ==)
903903
@@ -910,7 +910,7 @@ elemIndex a = findIndex (a ==)
910910-- > null = fmap isJust Fold.head
911911--
912912-- @since 0.7.0
913−{-# INLINABLE null #-}
913+{-# INLINE null #-}
914914null :: Monad m => Fold m a Bool
915915null = mkFold (\() _ -> Done False) (Partial ()) (const True)
916916
@@ -940,7 +940,7 @@ any predicate = mkFold_ step initial
940940-- > elem a = Fold.any (== a)
941941--
942942-- @since 0.7.0
943−{-# INLINABLE elem #-}
943+{-# INLINE elem #-}
944944elem :: (Eq a, Monad m) => a -> Fold m a Bool
945945elem a = any (a ==)
946946
@@ -952,7 +952,7 @@ elem a = any (a ==)
952952-- > all p = Fold.lmap p Fold.and
953953--
954954-- @since 0.7.0
955−{-# INLINABLE all #-}
955+{-# INLINE all #-}
956956all :: Monad m => (a -> Bool) -> Fold m a Bool
957957all predicate = mkFold_ step initial
958958
@@ -970,7 +970,7 @@ all predicate = mkFold_ step initial
970970-- > notElem a = Fold.all (/= a)
971971--
972972-- @since 0.7.0
973−{-# INLINABLE notElem #-}
973+{-# INLINE notElem #-}
974974notElem :: (Eq a, Monad m) => a -> Fold m a Bool
975975notElem a = all (a /=)
976976
@@ -1782,6 +1782,6 @@ toStream = fmap SerialT toStreamK
17821782-- /Pre-release/
17831783
17841784-- xn : ... : x2 : x1 : []
1785−{-# INLINABLE toStreamRev #-}
1785+{-# INLINE toStreamRev #-}
17861786toStreamRev :: Monad m => Fold m a (SerialT n a)
17871787toStreamRev = fmap SerialT toStreamKRev
src/Streamly/Internal/Data/Fold/Type.hs+7−7
@@ -541,7 +541,7 @@ drain = foldl' (\_ _ -> ()) ()
541541-- > toList = foldr (:) []
542542--
543543-- @since 0.7.0
544−{-# INLINABLE toList #-}
544+{-# INLINE toList #-}
545545toList :: Monad m => Fold m a [a]
546546toList = foldr (:) []
547547
@@ -556,7 +556,7 @@ toList = foldr (:) []
556556-- /Pre-release/
557557
558558-- xn : ... : x2 : x1 : []
559−{-# INLINABLE toStreamKRev #-}
559+{-# INLINE toStreamKRev #-}
560560toStreamKRev :: Monad m => Fold m a (K.Stream n a)
561561toStreamKRev = foldl' (flip K.cons) K.nil
562562
@@ -987,7 +987,7 @@ concatMap f (Fold stepa initiala extracta) = Fold stepc initialc extractc
987987-- > lmap = Fold.lmapM return
988988--
989989-- @since 0.8.0
990−{-# INLINABLE lmap #-}
990+{-# INLINE lmap #-}
991991lmap :: (a -> b) -> Fold m b r -> Fold m a r
992992lmap f (Fold step begin done) = Fold step' begin done
993993 where
@@ -996,7 +996,7 @@ lmap f (Fold step begin done) = Fold step' begin done
996996-- | @lmapM f fold@ maps the monadic function @f@ on the input of the fold.
997997--
998998-- @since 0.8.0
999−{-# INLINABLE lmapM #-}
999+{-# INLINE lmapM #-}
10001000lmapM :: Monad m => (a -> m b) -> Fold m b r -> Fold m a r
10011001lmapM f (Fold step begin done) = Fold step' begin done
10021002 where
@@ -1014,7 +1014,7 @@ lmapM f (Fold step begin done) = Fold step' begin done
10141014-- > filter f = Fold.filterM (return . f)
10151015--
10161016-- @since 0.8.0
1017−{-# INLINABLE filter #-}
1017+{-# INLINE filter #-}
10181018filter :: Monad m => (a -> Bool) -> Fold m a r -> Fold m a r
10191019filter f (Fold step begin done) = Fold step' begin done
10201020 where
@@ -1023,7 +1023,7 @@ filter f (Fold step begin done) = Fold step' begin done
10231023-- | Like 'filter' but with a monadic predicate.
10241024--
10251025-- @since 0.8.0
1026−{-# INLINABLE filterM #-}
1026+{-# INLINE filterM #-}
10271027filterM :: Monad m => (a -> m Bool) -> Fold m a r -> Fold m a r
10281028filterM f (Fold step begin done) = Fold step' begin done
10291029 where
@@ -1105,7 +1105,7 @@ take n (Fold fstep finitial fextract) = Fold step initial extract
11051105-- fold. Compare with 'snoc' which appends a singleton value to the fold.
11061106--
11071107-- /Pre-release/
1108−{-# INLINABLE duplicate #-}
1108+{-# INLINE duplicate #-}
11091109duplicate :: Monad m => Fold m a b -> Fold m a (Fold m a b)
11101110duplicate (Fold step1 initial1 extract1) =
11111111 Fold step initial (\s -> pure $ Fold step1 (pure $ Partial s) extract1)
src/Streamly/Internal/Data/Maybe/Strict.hs+3−3
@@ -29,20 +29,20 @@ where
2929data Maybe' a = Just' !a | Nothing' deriving Show
3030
3131-- | Convert strict Maybe' to lazy Maybe
32−{-# INLINABLE toMaybe #-}
32+{-# INLINE toMaybe #-}
3333toMaybe :: Maybe' a -> Maybe a
3434toMaybe Nothing' = Nothing
3535toMaybe (Just' a) = Just a
3636
3737-- | Extract the element out of a Just' and throws an error if its argument is
3838-- Nothing'.
39−{-# INLINABLE fromJust' #-}
39+{-# INLINE fromJust' #-}
4040fromJust' :: Maybe' a -> a
4141fromJust' (Just' a) = a
4242fromJust' Nothing' = error "fromJust' cannot be run in Nothing'"
4343
4444-- | Returns True iff its argument is of the form "Just' _".
45−{-# INLINABLE isJust' #-}
45+{-# INLINE isJust' #-}
4646isJust' :: Maybe' a -> Bool
4747isJust' (Just' _) = True
4848isJust' Nothing' = False
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+2−2
@@ -680,7 +680,7 @@ splitOnSeq patt f m =
680680-- | Like 'zipWith' but using a monadic zipping function.
681681--
682682-- @since 0.4.0
683−{-# INLINABLE zipWithM #-}
683+{-# INLINE zipWithM #-}
684684zipWithM :: (IsStream t, Monad m) => (a -> b -> m c) -> t m a -> t m b -> t m c
685685zipWithM f m1 m2 =
686686 IsStream.fromStreamS
@@ -699,7 +699,7 @@ zipWithM f m1 m2 =
699699-- @
700700--
701701-- @since 0.1.0
702−{-# INLINABLE zipWith #-}
702+{-# INLINE zipWith #-}
703703zipWith :: (IsStream t, Monad m) => (a -> b -> c) -> t m a -> t m b -> t m c
704704zipWith f m1 m2 =
705705 IsStream.fromStreamS
src/Streamly/Internal/Data/Stream/IsStream/Expand.hs+1−1
@@ -745,7 +745,7 @@ mergeBy f m1 m2 = fromStream $ K.mergeBy f (toStream m1) (toStream m2)
745745-- See also: 'mergeByMFused'
746746--
747747-- @since 0.6.0
748−{-# INLINABLE mergeByM #-}
748+{-# INLINE mergeByM #-}
749749mergeByM
750750 :: (IsStream t, Monad m)
751751 => (a -> a -> m Ordering) -> t m a -> t m a -> t m a
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+2−2
@@ -1492,7 +1492,7 @@ classifySessionsBy tick reset ejectPred tmout
14921492--
14931493-- /Pre-release/
14941494--
1495−{-# INLINABLE classifyKeepAliveSessions #-}
1495+{-# INLINE classifyKeepAliveSessions #-}
14961496classifyKeepAliveSessions ::
14971497 (IsStream t, MonadAsync m, Ord k)
14981498 => (Int -> m Bool) -- ^ predicate to eject sessions on session count
@@ -1539,7 +1539,7 @@ classifyChunksOf wsize = classifyChunksBy wsize False
15391539--
15401540-- /Pre-release/
15411541--
1542−{-# INLINABLE classifySessionsOf #-}
1542+{-# INLINE classifySessionsOf #-}
15431543classifySessionsOf ::
15441544 (IsStream t, MonadAsync m, Ord k)
15451545 => (Int -> m Bool) -- ^ predicate to eject sessions on session count
src/Streamly/Internal/Data/Stream/IsStream/Type.hs+1−1
@@ -654,7 +654,7 @@ concatMapWith par f xs = bindWith par xs f
654654-- /Since: 0.8.0 (Renamed foldMapWith to concatMapFoldableWith)/
655655--
656656-- /Since: 0.1.0 ("Streamly")/
657−{-# INLINABLE concatMapFoldableWith #-}
657+{-# INLINE concatMapFoldableWith #-}
658658concatMapFoldableWith :: (IsStream t, Foldable f)
659659 => (t m b -> t m b -> t m b) -> (a -> t m b) -> f a -> t m b
660660concatMapFoldableWith f g = Prelude.foldr (f . g) nil
src/Streamly/Internal/FileSystem/Dir.hs+1−1
@@ -103,7 +103,7 @@ readArrayUpto size h = do
103103-- | @toChunksWithBufferOf size h@ reads a stream of arrays from file handle @h@.
104104-- The maximum size of a single array is specified by @size@. The actual size
105105-- read may be less than or equal to @size@.
106−{-# INLINABLE _toChunksWithBufferOf #-}
106+{-# INLINE _toChunksWithBufferOf #-}
107107_toChunksWithBufferOf :: (IsStream t, MonadIO m)
108108 => Int -> Handle -> t m (Array Word8)
109109_toChunksWithBufferOf size h = go
src/Streamly/Internal/FileSystem/FD.hs+1−1
@@ -277,7 +277,7 @@ writeIOVec (Handle fd) iov =
277277-- | @readArraysOfUpto size h@ reads a stream of arrays from file handle @h@.
278278-- The maximum size of a single array is specified by @size@. The actual size
279279-- read may be less than or equal to @size@.
280−{-# INLINABLE _readArraysOfUpto #-}
280+{-# INLINE _readArraysOfUpto #-}
281281_readArraysOfUpto :: (IsStream t, MonadIO m)
282282 => Int -> Handle -> t m (Array Word8)
283283_readArraysOfUpto size h = go
src/Streamly/Internal/FileSystem/File.hs+4−4
@@ -151,14 +151,14 @@ withFile file mode = S.bracket (liftIO $ openFile file mode) (liftIO . hClose)
151151--
152152-- /Pre-release/
153153--
154−{-# INLINABLE usingFile #-}
154+{-# INLINE usingFile #-}
155155usingFile :: (MonadCatch m, MonadAsync m)
156156 => Unfold m Handle a -> Unfold m FilePath a
157157usingFile =
158158 UF.bracket (\file -> liftIO $ openFile file ReadMode)
159159 (liftIO . hClose)
160160
161−{-# INLINABLE usingFile2 #-}
161+{-# INLINE usingFile2 #-}
162162usingFile2 :: (MonadCatch m, MonadAsync m)
163163 => Unfold m (x, Handle) a -> Unfold m (x, FilePath) a
164164usingFile2 = UF.bracket before after
@@ -171,7 +171,7 @@ usingFile2 = UF.bracket before after
171171
172172 after (_, h) = liftIO $ hClose h
173173
174−{-# INLINABLE usingFile3 #-}
174+{-# INLINE usingFile3 #-}
175175usingFile3 :: (MonadCatch m, MonadAsync m)
176176 => Unfold m (x, y, z, Handle) a -> Unfold m (x, y, z, FilePath) a
177177usingFile3 = UF.bracket before after
@@ -215,7 +215,7 @@ appendArray file arr = SIO.withFile file AppendMode (`FH.putChunk` arr)
215215-- | @toChunksWithBufferOf size file@ reads a stream of arrays from file @file@.
216216-- The maximum size of a single array is specified by @size@. The actual size
217217-- read may be less than or equal to @size@.
218−{-# INLINABLE toChunksWithBufferOf #-}
218+{-# INLINE toChunksWithBufferOf #-}
219219toChunksWithBufferOf :: (IsStream t, MonadCatch m, MonadAsync m)
220220 => Int -> FilePath -> t m (Array Word8)
221221toChunksWithBufferOf size file =
src/Streamly/Internal/FileSystem/Handle.hs+1−1
@@ -206,7 +206,7 @@ getChunkOf = undefined
206206-- | @toChunksWithBufferOf size h@ reads a stream of arrays from file handle @h@.
207207-- The maximum size of a single array is specified by @size@. The actual size
208208-- read may be less than or equal to @size@.
209−{-# INLINABLE _toChunksWithBufferOf #-}
209+{-# INLINE _toChunksWithBufferOf #-}
210210_toChunksWithBufferOf :: (IsStream t, MonadIO m)
211211 => Int -> Handle -> t m (Array Word8)
212212_toChunksWithBufferOf size h = go
src/Streamly/Internal/Network/Inet/TCP.hs+4−4
@@ -277,7 +277,7 @@ withConnectionM addr port =
277277-- exception, then this exception will be raised by 'usingConnection'.
278278--
279279-- /Pre-release/
280−{-# INLINABLE usingConnection #-}
280+{-# INLINE usingConnection #-}
281281usingConnection :: (MonadCatch m, MonadAsync m)
282282 => Unfold m Socket a
283283 -> Unfold m ((Word8, Word8, Word8, Word8), PortNumber) a
@@ -297,7 +297,7 @@ usingConnection =
297297-- 'withConnection' rather than any exception raised by 'act'.
298298--
299299-- /Pre-release/
300−{-# INLINABLE withConnection #-}
300+{-# INLINE withConnection #-}
301301withConnection :: (IsStream t, MonadCatch m, MonadAsync m)
302302 => (Word8, Word8, Word8, Word8) -> PortNumber -> (Socket -> t m a) -> t m a
303303withConnection addr port =
@@ -418,7 +418,7 @@ write = writeWithBufferOf defaultChunkSize
418418-- Transformations
419419-------------------------------------------------------------------------------
420420
421−{-# INLINABLE withInputConnect #-}
421+{-# INLINE withInputConnect #-}
422422withInputConnect
423423 :: (IsStream t, MonadCatch m, MonadAsync m)
424424 => (Word8, Word8, Word8, Word8)
@@ -446,7 +446,7 @@ withInputConnect addr port input f = S.bracket pre post handler
446446--
447447-- /Pre-release/
448448--
449−{-# INLINABLE processBytes #-}
449+{-# INLINE processBytes #-}
450450processBytes
451451 :: (IsStream t, MonadAsync m, MonadCatch m)
452452 => (Word8, Word8, Word8, Word8)
src/Streamly/Internal/Network/Socket.hs+1−1
@@ -324,7 +324,7 @@ writeChunk = writeArrayWith sendAll
324324-- Stream of Arrays IO
325325-------------------------------------------------------------------------------
326326
327−{-# INLINABLE _readChunksUptoWith #-}
327+{-# INLINE _readChunksUptoWith #-}
328328_readChunksUptoWith :: (IsStream t, MonadIO m)
329329 => (Int -> h -> IO (Array Word8))
330330 -> Int -> h -> t m (Array Word8)