on master help sign in
Make some doc/doctest changes to MkType
17563f4Harendra Kumar
src/Streamly/Data/Stream/MkType.hs+17−18
@@ -10,49 +10,48 @@
10-- type, deriving all the usual instances.
10-- type, deriving all the usual instances.
11--
11--
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.
16--
16--
17−-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
17+-- >>> :set -XTemplateHaskell
18−-- >>> import Streamly.Internal.Data.Stream.MkType
18+-- >>> :set -XUndecidableInstances
19--
19--
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.
24--
22--
25-- Example, create an applicative type with zipping apply:
23-- Example, create an applicative type with zipping apply:
26--
24--
27−-- >>> import Streamly.Data.Stream.Prelude (Stream)
28-- >>> :{
25-- >>> :{
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)
31-- :}
28-- :}
32--
29--
33−-- > $(mkZipType "ZipStream" "zipApply" False)
34−--
35-- Example, create an applicative type with concurrent zipping apply:
30-- Example, create an applicative type with concurrent zipping apply:
36--
31--
32+-- >>> :{
33+-- parApply = Stream.parApply id
37−-- > $(mkZipType "ParZipStream" "parApply" True)
34+-- $(mkZipType "ParZipStream" "parApply" True)
35+-- :}
38--
36--
39-- Example, create a monad type with an interleaving cross product bind:
37-- Example, create a monad type with an interleaving cross product bind:
40--
38--
41-- >>> :{
39-- >>> :{
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)
44-- :}
42-- :}
45--
43--
46−-- > $(mkCrossType "InterleaveStream" "interleaveBind" False)
47−--
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:
49--
45--
50-- >>> :{
46-- >>> :{
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)
53-- :}
49-- :}
54--
50--
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.
56--
55--
57module Streamly.Data.Stream.MkType
56module Streamly.Data.Stream.MkType
58 (
57 (
@@ -78,4 +77,4 @@ import Streamly.Internal.Data.Stream.MkType
78-- >>> :m
77-- >>> :m
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