on master help sign in
Update the 0.9.0 upgrade guide
ec2856cHarendra Kumar
docs/User/Project/Upgrading.md → docs/User/Project/Upgrading-0.8-to-0.9.mdrenamed+86−8
@@ -1,9 +1,9 @@
1# Upgrading to streamly 0.9.0
1# Upgrading to streamly 0.9.0
2
2
3−Also see:
3+Also see the detailed changelog describing all the changes in the release:
4
4
5* [0.9.0 API Changelog](/docs/User/ProjectRelated/ApiChangelogs/0.8.3-0.9.0.txt) or
5* [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)
7
7
8`Streamly.Prelude` module has been deprecated, equivalent
8`Streamly.Prelude` module has been deprecated, equivalent
9functionality is covered by the `Streamly.Data.Stream`,
9functionality is covered by the `Streamly.Data.Stream`,
@@ -46,13 +46,14 @@ Assume the following imports in the code snippets below:
46
46
47## Dependencies in cabal file
47## Dependencies in cabal file
48
48
49−If you allow streamly < 0.9 in version bounds then you may not be able
49+If you allow streamly < 0.9 in version bounds in your package then you
50−to build if you:
50+may not be able to build if any of the following is true:
51
51
52−* also depend on the new `streamly-core` package (module name conflicts)
52+* there is a dependency on `streamly-core` (module name conflicts)
53−* depend on `streamly-bytestring` >= 0.2 (type conflict)
53+* there is a dependency on `streamly-bytestring` >= 0.2 (type conflict)
54
54
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:
56
57
57```
58```
58flag old-streamly
59flag old-streamly
@@ -103,6 +104,82 @@ ZipSerialM or WSerialT) with custom Applicative or Monadic properties.
103But in general, try to avoid specific types and use explicit functions
104But in general, try to avoid specific types and use explicit functions
104from the stream module.
105from the stream module.
105
106
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+
106`adapt` is not needed anymore.
183`adapt` is not needed anymore.
107
184
108```haskell docspec
185```haskell docspec
@@ -228,7 +305,8 @@ combinators are prefixed with `par`.
228Parallel combinators take a concurrency config argument to specify the
305Parallel combinators take a concurrency config argument to specify the
229concurrency control parameters. The following combinators have the same
306concurrency control parameters. The following combinators have the same
230meaning as before except that they are used to set the config parameters
307meaning 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+
232* `rate`
310* `rate`
233* `maxRate`
311* `maxRate`
234* `constRate`
312* `constRate`
streamly.cabal+1
@@ -167,6 +167,7 @@ extra-doc-files:
167 docs/User/Explanatory/*.md
167 docs/User/Explanatory/*.md
168 docs/User/Explanatory/streaming-pradigms.rst
168 docs/User/Explanatory/streaming-pradigms.rst
169 docs/User/Project/*.md
169 docs/User/Project/*.md
170+ docs/User/Project/Upgrading-0.8-to-0.9.md
170 docs/User/Project/*.link
171 docs/User/Project/*.link
171 docs/User/Project/ApiChangelogs/0.8.3-0.9.0.txt
172 docs/User/Project/ApiChangelogs/0.8.3-0.9.0.txt
172 docs/User/Project/ApiChangelogs/0.8.3.txt
173 docs/User/Project/ApiChangelogs/0.8.3.txt