on master help sign in
Expose doctest setup for StreamK module
ebe2472Harendra Kumar
core/src/DocTestDataStreamK.hsnew file+18
@@ -0,0 +1,18 @@
1+{- $setup
2+
3+>>> :m
4+>>> import Data.Function (fix, (&))
5+>>> import Data.Semigroup (cycle1)
6+
7+>>> import Streamly.Data.StreamK (StreamK)
8+>>> import qualified Streamly.Data.Fold as Fold
9+>>> import qualified Streamly.Data.Parser as Parser
10+>>> import qualified Streamly.Data.Stream as Stream
11+>>> import qualified Streamly.Data.StreamK as StreamK
12+>>> import qualified Streamly.FileSystem.Dir as Dir
13+
14+For APIs that have not been released yet.
15+
16+>>> import qualified Streamly.Internal.Data.Stream.StreamK as StreamK
17+>>> import qualified Streamly.Internal.FileSystem.Dir as Dir
18+-}
core/src/Streamly/Data/StreamK.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1-- |
2-- |
2-- Module : Streamly.Data.StreamK
3-- Module : Streamly.Data.StreamK
3-- Copyright : (c) 2017 Composewell Technologies
4-- Copyright : (c) 2017 Composewell Technologies
@@ -119,3 +120,5 @@ where
119
120
120import Streamly.Internal.Data.Stream.StreamK
121import Streamly.Internal.Data.Stream.StreamK
121import Prelude hiding (reverse, zipWith, mapM, dropWhile, take)
122import Prelude hiding (reverse, zipWith, mapM, dropWhile, take)
123+
124+#include "DocTestDataStreamK.hs"
core/src/Streamly/Internal/Data/Stream/StreamK.hs+2−8
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1-- |
2-- |
2-- Module : Streamly.Internal.Data.Stream.StreamK
3-- Module : Streamly.Internal.Data.Stream.StreamK
3-- Copyright : (c) 2017 Composewell Technologies
4-- Copyright : (c) 2017 Composewell Technologies
@@ -252,14 +253,7 @@ import Prelude
252import Streamly.Internal.Data.Stream.StreamK.Type
253import Streamly.Internal.Data.Stream.StreamK.Type
253import Streamly.Internal.Data.Parser.ParserD (ParseError(..))
254import Streamly.Internal.Data.Parser.ParserD (ParseError(..))
254
255
255−-- $setup
256+#include "DocTestDataStreamK.hs"
256−-- >>> :m
257−-- >>> import qualified Streamly.Data.Fold as Fold
258−-- >>> import qualified Streamly.Data.Parser as Parser
259−-- >>> import qualified Streamly.Data.Stream as Stream
260−-- >>> import qualified Streamly.Data.StreamK as StreamK
261−-- >>> import qualified Streamly.Internal.Data.Stream.StreamK as StreamK
262−--
263
257
264{-# INLINE fromStream #-}
258{-# INLINE fromStream #-}
265fromStream :: Monad m => Stream.Stream m a -> StreamK m a
259fromStream :: Monad m => Stream.Stream m a -> StreamK m a
core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs+5−12
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE UndecidableInstances #-}
2{-# LANGUAGE UndecidableInstances #-}
2-- |
3-- |
3-- Module : Streamly.Internal.Data.Stream.StreamK.Type
4-- Module : Streamly.Internal.Data.Stream.StreamK.Type
@@ -163,15 +164,7 @@ import qualified Prelude
163import Prelude hiding
164import Prelude hiding
164 (map, mapM, concatMap, foldr, repeat, null, reverse, tail, init)
165 (map, mapM, concatMap, foldr, repeat, null, reverse, tail, init)
165
166
166−-- $setup
167+#include "DocTestDataStreamK.hs"
167−-- >>> import Data.Function (fix, (&))
168−-- >>> import Data.Semigroup (cycle1)
169−-- >>> import Streamly.Internal.Data.Stream.StreamK (CrossStreamK(..))
170−-- >>> import qualified Streamly.Data.Fold as Fold
171−-- >>> import qualified Streamly.Data.Stream as Stream
172−-- >>> import qualified Streamly.Data.StreamK as StreamK
173−-- >>> import qualified Streamly.Internal.Data.Stream.StreamK as StreamK
174−-- >>> import qualified Streamly.Internal.FileSystem.Dir as Dir
175
168
176------------------------------------------------------------------------------
169------------------------------------------------------------------------------
177-- Basic stream type
170-- Basic stream type
@@ -315,7 +308,7 @@ nilM m = mkStream $ \_ _ _ stp -> m *> stp
315
308
316-- | Create a singleton stream from a pure value.
309-- | Create a singleton stream from a pure value.
317--
310--
318−-- >>> fromPure a = a `cons` StreamK.nil
311+-- >>> fromPure a = a `StreamK.cons` StreamK.nil
319-- >>> fromPure = pure
312-- >>> fromPure = pure
320-- >>> fromPure = StreamK.fromEffect . pure
313-- >>> fromPure = StreamK.fromEffect . pure
321--
314--
@@ -325,7 +318,7 @@ fromPure a = mkStream $ \_ _ single _ -> single a
325
318
326-- | Create a singleton stream from a monadic action.
319-- | Create a singleton stream from a monadic action.
327--
320--
328−-- >>> fromEffect m = m `consM` StreamK.nil
321+-- >>> fromEffect m = m `StreamK.consM` StreamK.nil
329--
322--
330-- >>> Stream.fold Fold.drain $ StreamK.toStream $ StreamK.fromEffect (putStrLn "hello")
323-- >>> Stream.fold Fold.drain $ StreamK.toStream $ StreamK.fromEffect (putStrLn "hello")
331-- hello
324-- hello
@@ -343,7 +336,7 @@ infixr 5 `consM`
343-- | A right associative prepend operation to add an effectful value at the
336-- | A right associative prepend operation to add an effectful value at the
344-- head of an existing stream::
337-- head of an existing stream::
345--
338--
346−-- >>> s = putStrLn "hello" `consM` putStrLn "world" `consM` StreamK.nil
339+-- >>> s = putStrLn "hello" `StreamK.consM` putStrLn "world" `StreamK.consM` StreamK.nil
347-- >>> Stream.fold Fold.drain (StreamK.toStream s)
340-- >>> Stream.fold Fold.drain (StreamK.toStream s)
348-- hello
341-- hello
349-- world
342-- world
core/streamly-core.cabal+1
@@ -44,6 +44,7 @@ extra-source-files:
44 src/DocTestDataMutArrayGeneric.hs
44 src/DocTestDataMutArrayGeneric.hs
45 src/DocTestDataParser.hs
45 src/DocTestDataParser.hs
46 src/DocTestDataStream.hs
46 src/DocTestDataStream.hs
47+ src/DocTestDataStreamK.hs
47
48
48 -- This is duplicated
49 -- This is duplicated
49 src/Streamly/Internal/Data/Array/ArrayMacros.h
50 src/Streamly/Internal/Data/Array/ArrayMacros.h