@@ -86,22 +86,23 @@ module Streaming.Internal (
8686
8787 ) where
8888
89+ import Control.Applicative
90+ import Control.Concurrent (threadDelay )
8991import Control.Monad
90- import Control.Monad.Trans
92+ import Control.Monad.Error.Class
93+ import Control.Monad.Morph
9194import Control.Monad.Reader.Class
9295import Control.Monad.State.Class
93- import Control.Monad.Error.Class
94- import Control.Applicative
96+ import Control.Monad.Trans
97+ import Data.Data ( Typeable )
9598import Data.Function ( on )
96- import Control.Monad.Morph
99+ import Data.Functor.Classes
100+ import Data.Functor.Compose
101+ import Data.Functor.Sum
97102import Data.Monoid (Monoid (.. ))
98103import Data.Semigroup (Semigroup (.. ))
99- import Data.Data (Typeable )
100104import Prelude hiding (splitAt )
101- import Data.Functor.Compose
102- import Data.Functor.Sum
103- import Data.Functor.Classes
104- import Control.Concurrent (threadDelay )
105+
105106{- $stream
106107
107108 The 'Stream' data type is equivalent to @FreeT@ and can represent any effectful
@@ -234,7 +235,7 @@ instance (Functor f, Monad m) => Monad (Stream f m) where
234235 (>>) = (*>)
235236 {-# INLINE (>>) #-}
236237 -- (>>=) = _bind
237- -- {-#INLINE (>>=) #-}
238+ -- {-# INLINE (>>=) #-}
238239 --
239240 stream >>= f =
240241 loop stream where
@@ -245,7 +246,7 @@ instance (Functor f, Monad m) => Monad (Stream f m) where
245246 {-# INLINABLE (>>=) #-}
246247
247248 fail = lift . fail
248- {-#INLINE fail #-}
249+ {-# INLINE fail #-}
249250
250251
251252-- _bind
@@ -258,7 +259,7 @@ instance (Functor f, Monad m) => Monad (Stream f m) where
258259-- Step fstr -> Step (fmap go fstr)
259260-- Effect m -> Effect (m >>= \s -> return (go s))
260261-- Return r -> f r
261- -- {-#INLINABLE _bind #-}
262+ -- {-# INLINABLE _bind #-}
262263--
263264-- see https://github.com/Gabriel439/Haskell-Pipes-Library/pull/163
264265-- for a plan to delay inlining and manage interaction with other operations.
@@ -294,21 +295,21 @@ instance (Functor f, Monad m) => Applicative (Stream f m) where
294295-}
295296instance (Applicative f , Monad m ) => Alternative (Stream f m ) where
296297 empty = never
297- {-#INLINE empty #-}
298+ {-# INLINE empty #-}
298299
299300 str <|> str' = zipsWith' liftA2 str str'
300- {-#INLINE (<|>) #-}
301+ {-# INLINE (<|>) #-}
301302
302303instance (Functor f , Monad m , Semigroup w ) => Semigroup (Stream f m w ) where
303304 a <> b = a >>= \ w -> fmap (w <> ) b
304- {-#INLINE (<>) #-}
305+ {-# INLINE (<>) #-}
305306
306307instance (Functor f , Monad m , Monoid w ) => Monoid (Stream f m w ) where
307308 mempty = return mempty
308- {-#INLINE mempty #-}
309+ {-# INLINE mempty #-}
309310#if !(MIN_VERSION_base(4,11,0))
310311 mappend a b = a >>= \ w -> fmap (w `mappend` ) b
311- {-#INLINE mappend #-}
312+ {-# INLINE mappend #-}
312313#endif
313314
314315instance (Applicative f , Monad m ) => MonadPlus (Stream f m ) where
@@ -421,7 +422,7 @@ streamFold
421422 :: (Functor f , Monad m ) =>
422423 (r -> b ) -> (m b -> b ) -> (f b -> b ) -> Stream f m r -> b
423424streamFold done theEffect construct stream = destroy stream construct theEffect done
424- {-#INLINE streamFold #-}
425+ {-# INLINE streamFold #-}
425426
426427{- | Reflect a church-encoded stream; cp. @GHC.Exts.build@
427428
@@ -742,7 +743,7 @@ distribute = loop where
742743 Return r -> lift (Return r)
743744 Effect tmstr -> hoist lift tmstr >>= loop
744745 Step fstr -> join (lift (Step (fmap (Return . loop) fstr)))
745- {-#INLINABLE distribute #-}
746+ {-# INLINABLE distribute #-}
746747
747748-- | Repeat a functorial layer (a \"command\" or \"instruction\") forever.
748749repeats :: (Monad m , Functor f ) => f () -> Stream f m r
@@ -889,7 +890,7 @@ unexposed = Effect . loop where
889890-}
890891wrap :: (Monad m , Functor f ) => f (Stream f m r ) -> Stream f m r
891892wrap = Step
892- {-#INLINE wrap #-}
893+ {-# INLINE wrap #-}
893894
894895
895896{- | Wrap an effect that returns a stream
@@ -899,7 +900,7 @@ wrap = Step
899900-}
900901effect :: (Monad m , Functor f ) => m (Stream f m r ) -> Stream f m r
901902effect = Effect
902- {-#INLINE effect #-}
903+ {-# INLINE effect #-}
903904
904905
905906{-| @yields@ is like @lift@ for items in the streamed functor.
@@ -916,7 +917,7 @@ effect = Effect
916917
917918yields :: (Monad m , Functor f ) => f r -> Stream f m r
918919yields fr = Step (fmap Return fr)
919- {-#INLINE yields #-}
920+ {-# INLINE yields #-}
920921
921922{-
922923Note that if the first stream produces Return, we don't inspect
@@ -1016,7 +1017,7 @@ interleaves = zipsWith' liftA2
10161017-}
10171018switch :: Sum f g r -> Sum g f r
10181019switch s = case s of InL a -> InR a; InR a -> InL a
1019- {-#INLINE switch #-}
1020+ {-# INLINE switch #-}
10201021
10211022
10221023
@@ -1070,7 +1071,7 @@ separate str = destroyExposed
10701071 (\ x -> case x of InL fss -> wrap fss; InR gss -> effect (yields gss))
10711072 (effect . lift)
10721073 return
1073- {-#INLINABLE separate #-}
1074+ {-# INLINABLE separate #-}
10741075
10751076
10761077
@@ -1080,7 +1081,7 @@ unseparate str = destroyExposed
10801081 (wrap . InL )
10811082 (join . maps InR )
10821083 return
1083- {-#INLINABLE unseparate #-}
1084+ {-# INLINABLE unseparate #-}
10841085
10851086-- | If 'Of' had a @Comonad@ instance, then we'd have
10861087--
@@ -1119,7 +1120,7 @@ unzips str = destroyExposed
11191120 (\ (Compose fgstr) -> Step (fmap (Effect . yields) fgstr))
11201121 (Effect . lift)
11211122 return
1122- {-#INLINABLE unzips #-}
1123+ {-# INLINABLE unzips #-}
11231124
11241125{-| Group layers in an alternating stream into adjoining sub-streams
11251126 of one type or another.
@@ -1156,7 +1157,7 @@ groups = loop
11561157 Left r -> return (return r)
11571158 Right (InL fstr) -> return (wrap (InL fstr))
11581159 Right (InR gstr) -> wrap (fmap go gstr)
1159- {-#INLINABLE groups #-}
1160+ {-# INLINABLE groups #-}
11601161
11611162-- groupInL :: (Monad m, Functor f, Functor g)
11621163-- => Stream (Sum f g) m r
@@ -1249,14 +1250,14 @@ never :: (Monad m, Applicative f) => Stream f m r
12491250-- The Monad m constraint should really be an Applicative one,
12501251-- but we still support old versions of base.
12511252never = let loop = Step $ pure (Effect (return loop)) in loop
1252- {-#INLINABLE never #-}
1253+ {-# INLINABLE never #-}
12531254
12541255
12551256delays :: (MonadIO m , Applicative f ) => Double -> Stream f m r
12561257delays seconds = loop where
12571258 loop = Effect $ liftIO (threadDelay delay) >> return (Step (pure loop))
12581259 delay = fromInteger (truncate (1000000 * seconds))
1259- {-#INLINABLE delays #-}
1260+ {-# INLINABLE delays #-}
12601261
12611262-- {-| Permit streamed actions to proceed unless the clock has run out.
12621263--
@@ -1275,7 +1276,7 @@ delays seconds = loop where
12751276-- loop str
12761277-- where
12771278-- cutoff = fromInteger (truncate (1000000000 * seconds))
1278- -- {-#INLINABLE period #-}
1279+ -- {-# INLINABLE period #-}
12791280--
12801281--
12811282-- {-| Divide a succession of phases according to a specified time interval. If time runs out
0 commit comments