on master help sign in
Update the 0.9.0 upgrade guide

Add more details about re-creating the older stream types.

commitec2856cbbd627c67e4b32eec45503a44c7a11cdc authorHarendra Kumar <harendra@composewell.com> dateMon 27 Nov 2023, 08:23 (3 years ago) parent5d9ce6e
2 files changed+87−8
docs/User/Project/Upgrading.md → docs/User/Project/Upgrading-0.8-to-0.9.md+86−8 streamly.cabal+1
docs/User/Project/Upgrading.md → docs/User/Project/Upgrading-0.8-to-0.9.mdrenamed+86−8
@@ -1,9 +1,9 @@
11# Upgrading to streamly 0.9.0
22
3−Also see:
3+Also see the detailed changelog describing all the changes in the release:
44
55* [0.9.0 API Changelog](/docs/User/ProjectRelated/ApiChangelogs/0.8.3-0.9.0.txt) or
6− https://hackage.haskell.org/package/streamly-0.9.0/docs/docs/User/ProjectRelated/ApiChangelogs/0.8.3-0.9.0.txt
6+* [0.9.0 API Changelog](https://hackage.haskell.org/package/streamly-0.9.0/docs/docs/User/ProjectRelated/ApiChangelogs/0.8.3-0.9.0.txt)
77
88`Streamly.Prelude` module has been deprecated, equivalent
99functionality is covered by the `Streamly.Data.Stream`,
@@ -46,13 +46,14 @@ Assume the following imports in the code snippets below:
4646
4747## Dependencies in cabal file
4848
49−If you allow streamly < 0.9 in version bounds then you may not be able
50−to build if you:
49+If you allow streamly < 0.9 in version bounds in your package then you
50+may not be able to build if any of the following is true:
5151
52−* also depend on the new `streamly-core` package (module name conflicts)
53−* depend on `streamly-bytestring` >= 0.2 (type conflict)
52+* there is a dependency on `streamly-core` (module name conflicts)
53+* there is a dependency on `streamly-bytestring` >= 0.2 (type conflict)
5454
55−You can use a build flag to allow older streamly versions:
55+You can define and use a build flag in your package to allow older
56+streamly versions:
5657
5758```
5859flag old-streamly
@@ -103,6 +104,82 @@ ZipSerialM or WSerialT) with custom Applicative or Monadic properties.
103104But in general, try to avoid specific types and use explicit functions
104105from the stream module.
105106
107+Here are the TH macro based recipes to define types equivalent to all the older
108+types:
109+
110+```
111+{-# LANGUAGE StandaloneDeriving #-}
112+{-# LANGUAGE TemplateHaskell #-}
113+{-# LANGUAGE TypeFamilies #-}
114+{-# LANGUAGE UndecidableInstances #-}
115+
116+import Streamly.Data.Stream.MkType
117+import qualified Streamly.Data.Stream.Prelude as Stream
118+import qualified Streamly.Internal.Data.StreamK as StreamK
119+import Language.Haskell.TH
120+```
121+
122+`SerialT`: Use `CrossStreamK` from `Streamly.Internal.Data.StreamK` equivalent
123+Monad and other instances.
124+
125+For `WSerialT`, create a newtype wrapper using the following monad bind
126+operation:
127+
128+```
129+bind = StreamK.bindWith StreamK.interleave
130+```
131+
132+`WSerialT` requires `StreamK`, therefore you can not generate the code directly
133+using TH macros. However, you can print the code generated by the TH macro.
134+Then you can tweak that code, replacing `Stream` type with `StreamK`.
135+
136+```
137+expr <- runQ (mkCrossType "WSerialT" "bind" True)
138+putStrLn $ pprint expr
139+```
140+
141+For `AsyncT`:
142+
143+```
144+bind = flip (Stream.parConcatMap id)
145+$(mkCrossType "AsyncT" "bind" True)
146+```
147+
148+For `WAsyncT`:
149+
150+```
151+bind = flip (Stream.parConcatMap (Stream.interleaved True))
152+$(mkCrossType "WAsyncT" "bind" True)
153+```
154+
155+For `AheadT`:
156+
157+```
158+bind = flip (Stream.parConcatMap (Stream.ordered True))
159+$(mkCrossType "AheadT" "bind" True)
160+```
161+
162+For `ParallelT`:
163+
164+```
165+bind = flip (Stream.parConcatMap (Stream.eager True))
166+$(mkCrossType "ParallelT" "bind" True)
167+```
168+
169+For `ZipSerialM`:
170+
171+```
172+apply = Stream.zipWith ($)
173+$(mkZipType "ZipSerialM" "apply" False)
174+```
175+
176+For `ZipAsync`:
177+
178+```
179+apply = Stream.parApply id
180+$(mkZipType "ZipAsync" "apply" False)
181+```
182+
106183`adapt` is not needed anymore.
107184
108185```haskell docspec
@@ -228,7 +305,8 @@ combinators are prefixed with `par`.
228305Parallel combinators take a concurrency config argument to specify the
229306concurrency control parameters. The following combinators have the same
230307meaning as before except that they are used to set the config parameters
231−instead of being applied on the stream.
308+instead of being applied on the stream:
309+
232310* `rate`
233311* `maxRate`
234312* `constRate`
streamly.cabal+1
@@ -167,6 +167,7 @@ extra-doc-files:
167167 docs/User/Explanatory/*.md
168168 docs/User/Explanatory/streaming-pradigms.rst
169169 docs/User/Project/*.md
170+ docs/User/Project/Upgrading-0.8-to-0.9.md
170171 docs/User/Project/*.link
171172 docs/User/Project/ApiChangelogs/0.8.3-0.9.0.txt
172173 docs/User/Project/ApiChangelogs/0.8.3.txt