Make some doc/doctest changes to MkType

This commit is contained in:
Harendra Kumar 2023-01-07 11:03:45 +05:30
parent 734d2cf874
commit 17563f4641

View File

@ -10,49 +10,48 @@
-- type, deriving all the usual instances.
--
-- To use this module, "Streamly.Data.Stream" or "Streamly.Data.Stream.Prelude"
-- must be imported as "Stream". Also, it is recommended to import this module
-- must be imported @as Stream@. Also, it is recommended to import this module
-- unqualified to bring everything needed in scope without having to import
-- several other modules.
--
-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
-- >>> import Streamly.Internal.Data.Stream.MkType
-- >>> :set -XTemplateHaskell
-- >>> :set -XUndecidableInstances
--
-- Instead of using these macros directly you could use the generated code as
-- well. Use these macros in ghci to generate the required code and paste it in
-- your package, you can customize it as you want. See the docs of the macros
-- below for examples of viewing the generated code.
-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
-- >>> import Streamly.Data.Stream.MkType
--
-- Example, create an applicative type with zipping apply:
--
-- >>> import Streamly.Data.Stream.Prelude (Stream)
-- >>> :{
-- zipApply :: Monad m => Stream m (a -> b) -> Stream m a -> Stream m b
-- zipApply = Stream.zipWith ($)
-- $(mkZipType "ZipStream" "zipApply" False)
-- :}
--
-- > $(mkZipType "ZipStream" "zipApply" False)
--
-- Example, create an applicative type with concurrent zipping apply:
--
-- > $(mkZipType "ParZipStream" "parApply" True)
-- >>> :{
-- parApply = Stream.parApply id
-- $(mkZipType "ParZipStream" "parApply" True)
-- :}
--
-- Example, create a monad type with an interleaving cross product bind:
--
-- >>> :{
-- interleaveBind :: Stream m a -> (a -> Stream m b) -> Stream m b
-- interleaveBind = flip (Stream.concatMapWith Stream.interleave)
-- $(mkCrossType "InterleaveStream" "interleaveBind" False)
-- :}
--
-- > $(mkCrossType "InterleaveStream" "interleaveBind" False)
--
-- Example, create a monad type with an eager concurrent cross product bind:
--
-- >>> :{
-- parBind :: Stream.MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b
-- parBind = flip (Stream.parConcatMap (Stream.eager True))
-- $(mkCrossType "ParEagerStream" "parBind" True)
-- :}
--
-- > $(mkCrossType "ParEagerStream" "parBind" True)
-- Instead of using these macros directly you could use the generated code as
-- well. Use these macros in ghci to generate the required code and paste it in
-- your package, you can customize the code as desired. See the docs of the
-- macros below for examples about how to view the generated code.
--
module Streamly.Data.Stream.MkType
(
@ -78,4 +77,4 @@ import Streamly.Internal.Data.Stream.MkType
-- >>> :m
-- >>> import Language.Haskell.TH
-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
-- >>> import Streamly.Internal.Data.Stream.MkType
-- >>> import Streamly.Data.Stream.MkType