@@ -6,55 +6,6 @@
66-- Stability : experimental
77-- Portability : GHC
88--
9−-- Template Haskell macros to create custom newtype wrappers for the 'Stream'
10−-- type, deriving all the usual instances.
11−--
12−-- To use this module, "Streamly.Data.Stream" or "Streamly.Data.Stream.Prelude"
13−-- must be imported as "Stream". Also, it is recommended to import this module
14−-- unqualified to bring everything needed in scope without having to import
15−-- several other modules.
16−--
17−-- >>> import Control.Monad.Reader.Class (MonadReader(..))
18−-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
19−-- >>> import Streamly.Internal.Data.Stream.MkType
20−--
21−-- Instead of using these macros directly you could use the generated code as
22−-- well. Use these macros in ghci to generate the required code and paste it in
23−-- your package, you can customize it as you want. See the docs of the macros
24−-- below for examples of viewing the generated code.
25−--
26−-- Example, create an applicative type with zipping apply:
27−--
28−-- >>> import Streamly.Data.Stream.Prelude (Stream)
29−-- >>> :{
30−-- zipApply :: Monad m => Stream m (a -> b) -> Stream m a -> Stream m b
31−-- zipApply = Stream.zipWith ($)
32−-- :}
33−--
34−-- > $(mkZipType "ZipStream" "zipApply" False)
35−--
36−-- Example, create an applicative type with concurrent zipping apply:
37−--
38−-- > $(mkZipType "ParZipStream" "parApply" True)
39−--
40−-- Example, create a monad type with an interleaving cross product bind:
41−--
42−-- >>> :{
43−-- interleaveBind :: Stream m a -> (a -> Stream m b) -> Stream m b
44−-- interleaveBind = flip (Stream.concatMapWith Stream.interleave)
45−-- :}
46−--
47−-- > $(mkCrossType "InterleaveStream" "interleaveBind" False)
48−--
49−-- Example, create a monad type with an eager concurrent cross product bind:
50−--
51−-- >>> :{
52−-- parBind :: Stream.MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b
53−-- parBind = flip (Stream.parConcatMap (Stream.eager True))
54−-- :}
55−--
56−-- > $(mkCrossType "ParEagerStream" "parBind" True)
57−--
589module Streamly.Internal.Data.Stream.MkType
5910 (
6011 -- * Imports for Examples
@@ -67,7 +18,7 @@ module Streamly.Internal.Data.Stream.MkType
6718 -- * Re-exports
6819 , MonadIO(..)
6920 , MonadThrow(..)
70− -- , MonadReader(..)
21+ , MonadReader(..)
7122 , MonadTrans(..)
7223 , ap
7324 ) where
@@ -82,16 +33,13 @@ import Language.Haskell.TH.Syntax
8233import Control.Monad (ap)
8334import Control.Monad.Catch (MonadThrow(..))
8435import Control.Monad.IO.Class (MonadIO(..))
85−-- import Control.Monad.Reader.Class (MonadReader(..))
36+import Control.Monad.Reader.Class (MonadReader(..))
8637import Control.Monad.Trans.Class (MonadTrans(..))
8738import Prelude hiding (repeat)
8839
8940-- $setup
9041-- >>> :m
91−-- >>> :set -package mtl
92−-- >>> :set -package streamly
9342-- >>> import Language.Haskell.TH
94−-- >>> import Control.Monad.Reader.Class (MonadReader(..))
9543-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
9644-- >>> import Streamly.Internal.Data.Stream.MkType
9745
@@ -391,7 +339,7 @@ mkSimpleStreamInstances dtNameStr = do
391339 []
392340 ]
393341 ]
394− reader <-
342+ rdr <-
395343 instanceD
396344 (sequence
397345 [ appT (conT _Monad) (appT (conT _Type) (varT _m))
@@ -416,7 +364,7 @@ mkSimpleStreamInstances dtNameStr = do
416364 []
417365 ]
418366 ]
419− return [trans, io, throw, reader]
367+ return [trans, io, throw, rdr]
420368
421369 where
422370