on master help sign in
Make some doc/doctest changes to MkType
commit17563f46418a26ad57e197922a9f64805de95d13 authorHarendra Kumar <harendra@composewell.com> dateSat 7 Jan 2023, 11:03 (4 years ago) parent734d2cf
1 file changed+17−18
src/Streamly/Data/Stream/MkType.hs+17−18
src/Streamly/Data/Stream/MkType.hs+17−18
@@ -10,49 +10,48 @@
1010-- type, deriving all the usual instances.
1111--
1212-- 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
1414-- unqualified to bring everything needed in scope without having to import
1515-- several other modules.
1616--
17−-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
18−-- >>> import Streamly.Internal.Data.Stream.MkType
17+-- >>> :set -XTemplateHaskell
18+-- >>> :set -XUndecidableInstances
1919--
20−-- Instead of using these macros directly you could use the generated code as
21−-- well. Use these macros in ghci to generate the required code and paste it in
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.
20+-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
21+-- >>> import Streamly.Data.Stream.MkType
2422--
2523-- Example, create an applicative type with zipping apply:
2624--
27−-- >>> import Streamly.Data.Stream.Prelude (Stream)
2825-- >>> :{
29−-- zipApply :: Monad m => Stream m (a -> b) -> Stream m a -> Stream m b
3026-- zipApply = Stream.zipWith ($)
27+-- $(mkZipType "ZipStream" "zipApply" False)
3128-- :}
3229--
33−-- > $(mkZipType "ZipStream" "zipApply" False)
34−--
3530-- Example, create an applicative type with concurrent zipping apply:
3631--
37−-- > $(mkZipType "ParZipStream" "parApply" True)
32+-- >>> :{
33+-- parApply = Stream.parApply id
34+-- $(mkZipType "ParZipStream" "parApply" True)
35+-- :}
3836--
3937-- Example, create a monad type with an interleaving cross product bind:
4038--
4139-- >>> :{
42−-- interleaveBind :: Stream m a -> (a -> Stream m b) -> Stream m b
4340-- interleaveBind = flip (Stream.concatMapWith Stream.interleave)
41+-- $(mkCrossType "InterleaveStream" "interleaveBind" False)
4442-- :}
4543--
46−-- > $(mkCrossType "InterleaveStream" "interleaveBind" False)
47−--
4844-- Example, create a monad type with an eager concurrent cross product bind:
4945--
5046-- >>> :{
51−-- parBind :: Stream.MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b
5247-- parBind = flip (Stream.parConcatMap (Stream.eager True))
48+-- $(mkCrossType "ParEagerStream" "parBind" True)
5349-- :}
5450--
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.
5655--
5756module Streamly.Data.Stream.MkType
5857 (
@@ -78,4 +77,4 @@ import Streamly.Internal.Data.Stream.MkType
7877-- >>> :m
7978-- >>> import Language.Haskell.TH
8079-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
81−-- >>> import Streamly.Internal.Data.Stream.MkType
80+-- >>> import Streamly.Data.Stream.MkType