@@ -10,49 +10,48 @@
10-- type, deriving all the usual instances.
10-- type, deriving all the usual instances.
12-- To use this module, "Streamly.Data.Stream" or "Streamly.Data.Stream.Prelude"
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
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
14-- unqualified to bring everything needed in scope without having to import
15-- several other modules.
15-- several other modules.
17−-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
17+-- >>> :set -XTemplateHaskell
18−-- >>> import Streamly.Internal.Data.Stream.MkType
18+-- >>> :set -XUndecidableInstances
20−-- Instead of using these macros directly you could use the generated code as
20+-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
21−-- well. Use these macros in ghci to generate the required code and paste it in
21+-- >>> import Streamly.Data.Stream.MkType
22−-- your package, you can customize it as you want. See the docs of the macros
23−-- below for examples of viewing the generated code.
25-- Example, create an applicative type with zipping apply:
23-- Example, create an applicative type with zipping apply:
27−-- >>> import Streamly.Data.Stream.Prelude (Stream)
29−-- zipApply :: Monad m => Stream m (a -> b) -> Stream m a -> Stream m b
30-- zipApply = Stream.zipWith ($)
26-- zipApply = Stream.zipWith ($)
27+-- $(mkZipType "ZipStream" "zipApply" False)
33−-- > $(mkZipType "ZipStream" "zipApply" False)
35-- Example, create an applicative type with concurrent zipping apply:
30-- Example, create an applicative type with concurrent zipping apply:
33+-- parApply = Stream.parApply id
37−-- > $(mkZipType "ParZipStream" "parApply" True)
34+-- $(mkZipType "ParZipStream" "parApply" True)
39-- Example, create a monad type with an interleaving cross product bind:
37-- Example, create a monad type with an interleaving cross product bind:
42−-- interleaveBind :: Stream m a -> (a -> Stream m b) -> Stream m b
43-- interleaveBind = flip (Stream.concatMapWith Stream.interleave)
40-- interleaveBind = flip (Stream.concatMapWith Stream.interleave)
41+-- $(mkCrossType "InterleaveStream" "interleaveBind" False)
46−-- > $(mkCrossType "InterleaveStream" "interleaveBind" False)
48-- Example, create a monad type with an eager concurrent cross product bind:
44-- Example, create a monad type with an eager concurrent cross product bind:
51−-- parBind :: Stream.MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b
52-- parBind = flip (Stream.parConcatMap (Stream.eager True))
47-- parBind = flip (Stream.parConcatMap (Stream.eager True))
48+-- $(mkCrossType "ParEagerStream" "parBind" True)
55−-- > $(mkCrossType "ParEagerStream" "parBind" True)
51+-- Instead of using these macros directly you could use the generated code as
52+-- well. Use these macros in ghci to generate the required code and paste it in
53+-- your package, you can customize the code as desired. See the docs of the
54+-- macros below for examples about how to view the generated code.
57module Streamly.Data.Stream.MkType
56module Streamly.Data.Stream.MkType
@@ -78,4 +77,4 @@ import Streamly.Internal.Data.Stream.MkType
79-- >>> import Language.Haskell.TH
78-- >>> import Language.Haskell.TH
80-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
79-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
81−-- >>> import Streamly.Internal.Data.Stream.MkType
80+-- >>> import Streamly.Data.Stream.MkType