@@ -6,55 +6,6 @@
6-- Stability : experimental
6-- Stability : experimental
7-- Portability : GHC
7-- Portability : GHC
9−-- Template Haskell macros to create custom newtype wrappers for the 'Stream'
10−-- type, deriving all the usual instances.
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.
17−-- >>> import Control.Monad.Reader.Class (MonadReader(..))
18−-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
19−-- >>> import Streamly.Internal.Data.Stream.MkType
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.
26−-- Example, create an applicative type with zipping apply:
28−-- >>> import Streamly.Data.Stream.Prelude (Stream)
30−-- zipApply :: Monad m => Stream m (a -> b) -> Stream m a -> Stream m b
31−-- zipApply = Stream.zipWith ($)
34−-- > $(mkZipType "ZipStream" "zipApply" False)
36−-- Example, create an applicative type with concurrent zipping apply:
38−-- > $(mkZipType "ParZipStream" "parApply" True)
40−-- Example, create a monad type with an interleaving cross product bind:
43−-- interleaveBind :: Stream m a -> (a -> Stream m b) -> Stream m b
44−-- interleaveBind = flip (Stream.concatMapWith Stream.interleave)
47−-- > $(mkCrossType "InterleaveStream" "interleaveBind" False)
49−-- Example, create a monad type with an eager concurrent cross product bind:
52−-- parBind :: Stream.MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b
53−-- parBind = flip (Stream.parConcatMap (Stream.eager True))
56−-- > $(mkCrossType "ParEagerStream" "parBind" True)
58module Streamly.Internal.Data.Stream.MkType
9module Streamly.Internal.Data.Stream.MkType
60 -- * Imports for Examples
11 -- * Imports for Examples
@@ -67,7 +18,7 @@ module Streamly.Internal.Data.Stream.MkType
67 -- * Re-exports
18 -- * Re-exports
68 , MonadIO(..)
19 , MonadIO(..)
69 , MonadThrow(..)
20 , MonadThrow(..)
70− -- , MonadReader(..)
21+ , MonadReader(..)
71 , MonadTrans(..)
22 , MonadTrans(..)
@@ -82,16 +33,13 @@ import Language.Haskell.TH.Syntax
82import Control.Monad (ap)
33import Control.Monad (ap)
83import Control.Monad.Catch (MonadThrow(..))
34import Control.Monad.Catch (MonadThrow(..))
84import Control.Monad.IO.Class (MonadIO(..))
35import Control.Monad.IO.Class (MonadIO(..))
85−-- import Control.Monad.Reader.Class (MonadReader(..))
36+import Control.Monad.Reader.Class (MonadReader(..))
86import Control.Monad.Trans.Class (MonadTrans(..))
37import Control.Monad.Trans.Class (MonadTrans(..))
87import Prelude hiding (repeat)
38import Prelude hiding (repeat)
91−-- >>> :set -package mtl
92−-- >>> :set -package streamly
93-- >>> import Language.Haskell.TH
42-- >>> import Language.Haskell.TH
94−-- >>> import Control.Monad.Reader.Class (MonadReader(..))
95-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
43-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
96-- >>> import Streamly.Internal.Data.Stream.MkType
44-- >>> import Streamly.Internal.Data.Stream.MkType
@@ -391,7 +339,7 @@ mkSimpleStreamInstances dtNameStr = do
394− reader <-
342+ rdr <-
395 instanceD
343 instanceD
396 (sequence
344 (sequence
397 [ appT (conT _Monad) (appT (conT _Type) (varT _m))
345 [ appT (conT _Monad) (appT (conT _Type) (varT _m))
@@ -416,7 +364,7 @@ mkSimpleStreamInstances dtNameStr = do
419− return [trans, io, throw, reader]
367+ return [trans, io, throw, rdr]