on master help sign in
Remove MonadTrans/MonadBase instances for GHC >= 9.6

Remove MonadTrans/MonadBase instances for: * ParallelT * AsyncT * WAsyncT * AheadT To accommodate a breaking change in transformers-0.6 .

commit4ccd51c2b82d825be8b55670af8e7441d23b5520 authorHarendra Kumar <harendra@composewell.com> dateFri 30 Jun 2023, 13:54 (3 years ago) parent8d7b837
9 files changed+92−40
docs/User/ProjectRelated/Changelog.md+9 docs/streamly-docs.cabal+1−1 src/Streamly/Internal/Data/Stream/Ahead.hs+11 src/Streamly/Internal/Data/Stream/Async.hs+18 src/Streamly/Internal/Data/Stream/Instances.hs+6−9 src/Streamly/Internal/Data/Stream/Parallel.hs+11 src/Streamly/Internal/Data/Stream/Serial.hs+9 streamly.cabal+14−17 test/streamly-tests.cabal+13−13
docs/User/ProjectRelated/Changelog.md+9
@@ -2,6 +2,15 @@
22
33<!-- See rendered changelog at https://streamly.composewell.com -->
44
5+## Unreleased
6+
7+### Breaking Changes
8+
9+* MonadTrans and MonadBase instances has been removed for `AsyncT`,
10+ `ParallelT`, `AheadT` for GHC versions 9.6 onwards. This is due to a
11+ breaking change in `transformers` 0.6. You can replace `lift` with
12+ `fromEffect` when using these as top level monads in a monad stack.
13+
514## 0.9.0 (Mar 2023)
615
716Also see the following:
docs/streamly-docs.cabal+1−1
@@ -44,6 +44,6 @@ library
4444
4545 build-depends:
4646 base >= 4.9 && < 4.19
47− , transformers >= 0.4 && < 0.6.2
47+ , transformers >= 0.4 && < 0.7
4848 , streamly
4949 , streamly-core
src/Streamly/Internal/Data/Stream/Ahead.hs+11
@@ -34,13 +34,17 @@ where
3434import Control.Concurrent.MVar (putMVar, takeMVar)
3535import Control.Exception (assert)
3636import Control.Monad (void, when)
37+#if !(MIN_VERSION_transformers(0,6,0))
3738import Control.Monad.Base (MonadBase(..), liftBaseDefault)
39+#endif
3840import Control.Monad.Catch (MonadThrow, throwM)
3941-- import Control.Monad.Error.Class (MonadError(..))
4042import Control.Monad.IO.Class (MonadIO(..))
4143import Control.Monad.Reader.Class (MonadReader(..))
4244import Control.Monad.State.Class (MonadState(..))
45+#if !(MIN_VERSION_transformers(0,6,0))
4346import Control.Monad.Trans.Class (MonadTrans(lift))
47+#endif
4448import Data.Heap (Heap, Entry(..))
4549import Data.IORef (IORef, readIORef, atomicModifyIORef, writeIORef)
4650import Data.Maybe (fromJust)
@@ -693,9 +697,11 @@ consM m (AheadT r) = AheadT $ aheadK (K.fromEffect m) r
693697-- @since 0.8.0
694698newtype AheadT m a = AheadT {getAheadT :: Stream m a}
695699
700+#if !(MIN_VERSION_transformers(0,6,0))
696701instance MonadTrans AheadT where
697702 {-# INLINE lift #-}
698703 lift = AheadT . K.fromEffect
704+#endif
699705
700706-- | A serial IO stream of elements of type @a@ with concurrent lookahead. See
701707-- 'AheadT' documentation for more details.
@@ -762,4 +768,9 @@ instance MonadAsync m => Monad (AheadT m) where
762768-- Other instances
763769------------------------------------------------------------------------------
764770
771+#if !(MIN_VERSION_transformers(0,6,0))
772+instance (MonadBase b m, Monad m, MonadAsync m) => MonadBase b (AheadT m) where
773+ liftBase = liftBaseDefault
774+#endif
775+
765776MONAD_COMMON_INSTANCES(AheadT, MONADPARALLEL)
src/Streamly/Internal/Data/Stream/Async.hs+18
@@ -41,14 +41,18 @@ module Streamly.Internal.Data.Stream.Async {-# DEPRECATED "Please use \"Streamly
4141where
4242
4343import Control.Concurrent (myThreadId)
44+#if !(MIN_VERSION_transformers(0,6,0))
4445import Control.Monad.Base (MonadBase(..), liftBaseDefault)
46+#endif
4547import Control.Monad.Catch (MonadThrow, throwM)
4648import Control.Concurrent.MVar (newEmptyMVar)
4749-- import Control.Monad.Error.Class (MonadError(..))
4850import Control.Monad.IO.Class (MonadIO(..))
4951import Control.Monad.Reader.Class (MonadReader(..))
5052import Control.Monad.State.Class (MonadState(..))
53+#if !(MIN_VERSION_transformers(0,6,0))
5154import Control.Monad.Trans.Class (MonadTrans(lift))
55+#endif
5256import Data.Concurrent.Queue.MichaelScott (LinkedQueue, newQ, nullQ, tryPopR, pushL)
5357import Data.IORef (IORef, newIORef, readIORef)
5458import Data.Maybe (fromJust)
@@ -745,9 +749,11 @@ consMAsync m (AsyncT r) = AsyncT $ asyncK (K.fromEffect m) r
745749-- @since 0.8.0
746750newtype AsyncT m a = AsyncT {getAsyncT :: Stream m a}
747751
752+#if !(MIN_VERSION_transformers(0,6,0))
748753instance MonadTrans AsyncT where
749754 {-# INLINE lift #-}
750755 lift = AsyncT . K.fromEffect
756+#endif
751757
752758-- | A demand driven left biased parallely composing IO stream of elements of
753759-- type @a@. See 'AsyncT' documentation for more details.
@@ -819,6 +825,11 @@ instance MonadAsync m => Monad (AsyncT m) where
819825-- Other instances
820826------------------------------------------------------------------------------
821827
828+#if !(MIN_VERSION_transformers(0,6,0))
829+instance (MonadBase b m, Monad m, MonadAsync m) => MonadBase b (AsyncT m) where
830+ liftBase = liftBaseDefault
831+#endif
832+
822833MONAD_COMMON_INSTANCES(AsyncT, MONADPARALLEL)
823834
824835------------------------------------------------------------------------------
@@ -971,9 +982,11 @@ consMWAsync m (WAsyncT r) = WAsyncT $ wAsyncK (K.fromEffect m) r
971982--
972983newtype WAsyncT m a = WAsyncT {getWAsyncT :: Stream m a}
973984
985+#if !(MIN_VERSION_transformers(0,6,0))
974986instance MonadTrans WAsyncT where
975987 {-# INLINE lift #-}
976988 lift = WAsyncT . K.fromEffect
989+#endif
977990
978991-- | A round robin parallely composing IO stream of elements of type @a@.
979992-- See 'WAsyncT' documentation for more details.
@@ -1043,4 +1056,9 @@ instance MonadAsync m => Monad (WAsyncT m) where
10431056-- Other instances
10441057------------------------------------------------------------------------------
10451058
1059+#if !(MIN_VERSION_transformers(0,6,0))
1060+instance (MonadBase b m, Monad m, MonadAsync m) => MonadBase b (WAsyncT m) where
1061+ liftBase = liftBaseDefault
1062+#endif
1063+
10461064MONAD_COMMON_INSTANCES(WAsyncT, MONADPARALLEL)
src/Streamly/Internal/Data/Stream/Instances.hs+6−9
@@ -15,14 +15,11 @@ instance Monad m => Functor (STREAM m) where { \
1515 {-# INLINE (<$) #-}; \
1616 (<$) = fmap . const }; \
1717 \
18−instance (MonadBase b m, Monad m CONSTRAINT) => MonadBase b (STREAM m) where {\
19− liftBase = liftBaseDefault }; \
20− \
2118instance (MonadIO m CONSTRAINT) => MonadIO (STREAM m) where { \
22− liftIO = lift . liftIO }; \
19+ liftIO x = STREAM $ K.fromEffect $ liftIO x }; \
2320 \
2421instance (MonadThrow m CONSTRAINT) => MonadThrow (STREAM m) where { \
25− throwM = lift . throwM }; \
22+ throwM x = STREAM $ K.fromEffect $ throwM x }; \
2623 \
2724{- \
2825instance (MonadError e m CONSTRAINT) => MonadError e (STREAM m) where { \
@@ -32,16 +29,16 @@ instance (MonadError e m CONSTRAINT) => MonadError e (STREAM m) where { \
3229-} \
3330 \
3431instance (MonadReader r m CONSTRAINT) => MonadReader r (STREAM m) where { \
35− ask = lift ask; \
32+ ask = STREAM $ K.fromEffect ask; \
3633 local f (STREAM m) = STREAM $ withLocal f m }; \
3734 \
3835instance (MonadState s m CONSTRAINT) => MonadState s (STREAM m) where { \
3936 {-# INLINE get #-}; \
40− get = lift get; \
37+ get = STREAM $ K.fromEffect get; \
4138 {-# INLINE put #-}; \
42− put x = lift (put x); \
39+ put x = STREAM $ K.fromEffect $ put x; \
4340 {-# INLINE state #-}; \
44− state k = lift (state k) }
41+ state k = STREAM $ K.fromEffect $ state k }
4542
4643------------------------------------------------------------------------------
4744-- Lists
src/Streamly/Internal/Data/Stream/Parallel.hs+11
@@ -49,13 +49,17 @@ where
4949
5050import Control.Concurrent (myThreadId, takeMVar)
5151import Control.Monad (when)
52+#if !(MIN_VERSION_transformers(0,6,0))
5253import Control.Monad.Base (MonadBase(..), liftBaseDefault)
54+#endif
5355import Control.Monad.Catch (MonadThrow, throwM)
5456-- import Control.Monad.Error.Class (MonadError(..))
5557import Control.Monad.IO.Class (MonadIO(..))
5658import Control.Monad.Reader.Class (MonadReader(..))
5759import Control.Monad.State.Class (MonadState(..))
60+#if !(MIN_VERSION_transformers(0,6,0))
5861import Control.Monad.Trans.Class (MonadTrans(lift))
62+#endif
5963import Data.Functor (void)
6064import Data.IORef (readIORef, writeIORef)
6165import Data.Maybe (fromJust)
@@ -432,9 +436,11 @@ tapAsyncF f (D.Stream step1 state1) = D.Stream step TapInit
432436-- @since 0.8.0
433437newtype ParallelT m a = ParallelT {getParallelT :: K.StreamK m a}
434438
439+#if !(MIN_VERSION_transformers(0,6,0))
435440instance MonadTrans ParallelT where
436441 {-# INLINE lift #-}
437442 lift = ParallelT . K.fromEffect
443+#endif
438444
439445-- | A parallely composing IO stream of elements of type @a@.
440446-- See 'ParallelT' documentation for more details.
@@ -504,6 +510,11 @@ instance MonadAsync m => Monad (ParallelT m) where
504510-- Other instances
505511------------------------------------------------------------------------------
506512
513+#if !(MIN_VERSION_transformers(0,6,0))
514+instance (MonadBase b m, Monad m, MonadAsync m) => MonadBase b (ParallelT m) where
515+ liftBase = liftBaseDefault
516+#endif
517+
507518MONAD_COMMON_INSTANCES(ParallelT, MONADPARALLEL)
508519
509520-------------------------------------------------------------------------------
src/Streamly/Internal/Data/Stream/Serial.hs+9
@@ -48,9 +48,13 @@ module Streamly.Internal.Data.Stream.Serial {-# DEPRECATED "Please use \"Streaml
4848 )
4949where
5050
51+#if !(MIN_VERSION_base(4,18,0))
5152import Control.Applicative (liftA2)
53+#endif
5254import Control.DeepSeq (NFData(..), NFData1(..))
55+#if !(MIN_VERSION_transformers(0,6,0))
5356import Control.Monad.Base (MonadBase(..), liftBaseDefault)
57+#endif
5458import Control.Monad.Catch (MonadThrow, throwM)
5559import Control.Monad.IO.Class (MonadIO(..))
5660import Control.Monad.Reader.Class (MonadReader(..))
@@ -408,6 +412,11 @@ instance Monad m => Monad (WSerialT m) where
408412-- Other instances
409413------------------------------------------------------------------------------
410414
415+#if !(MIN_VERSION_transformers(0,6,0))
416+instance (MonadBase b m, Monad m) => MonadBase b (SerialT m) where
417+ liftBase = liftBaseDefault
418+#endif
419+
411420MONAD_COMMON_INSTANCES(WSerialT,)
412421LIST_INSTANCES(WSerialT)
413422NFDATA1_INSTANCE(WSerialT)
streamly.cabal+14−17
@@ -401,25 +401,12 @@ library
401401 , Streamly.Network.Socket
402402 , Streamly.Network.Inet.TCP
403403
404− -- Deprecated modules
404+ -- Deprecated
405+ , Streamly
406+ , Streamly.Data.Unicode.Stream
405407 , Streamly.Memory.Array
406408 , Streamly.Data.Array.Foreign
407−
408− if !impl(ghcjs) && flag(dev)
409− exposed-modules:
410− Streamly.Internal.System.IOVec.Type
411− , Streamly.Internal.System.IOVec
412− , Streamly.Internal.FileSystem.FDIO
413− , Streamly.Internal.FileSystem.FD
414−
415− if impl(ghc <= 9.4.5)
416− exposed-modules:
417− Streamly
418− , Streamly.Data.Unicode.Stream
419409 , Streamly.Prelude
420− , Streamly.Internal.Data.Stream.Async
421− , Streamly.Internal.Data.Stream.Parallel
422− , Streamly.Internal.Data.Stream.Ahead
423410
424411 -- Deprecated Internal modules
425412 , Streamly.Internal.Data.SVar.Worker
@@ -435,6 +422,9 @@ library
435422
436423 , Streamly.Internal.Data.Stream.Serial
437424 , Streamly.Internal.Data.Stream.Zip
425+ , Streamly.Internal.Data.Stream.Async
426+ , Streamly.Internal.Data.Stream.Parallel
427+ , Streamly.Internal.Data.Stream.Ahead
438428 , Streamly.Internal.Data.Stream.ZipAsync
439429
440430 , Streamly.Internal.Data.Stream.IsStream.Type
@@ -451,6 +441,13 @@ library
451441 , Streamly.Internal.Data.Stream.IsStream.Top
452442 , Streamly.Internal.Data.Stream.IsStream
453443
444+ if !impl(ghcjs) && flag(dev)
445+ exposed-modules:
446+ Streamly.Internal.System.IOVec.Type
447+ , Streamly.Internal.System.IOVec
448+ , Streamly.Internal.FileSystem.FDIO
449+ , Streamly.Internal.FileSystem.FD
450+
454451 if flag(dev)
455452 exposed-modules: Streamly.Data.SmallArray
456453 , Streamly.Internal.Data.SmallArray
@@ -506,7 +503,7 @@ library
506503 -- Network
507504 , network >= 2.6 && < 3.2
508505
509− if impl(ghc <= 9.4.5)
506+ if impl(ghc < 9.6)
510507 build-depends: transformers-base >= 0.4 && < 0.5
511508
512509 if flag(use-unliftio)
test/streamly-tests.cabal+13−13
@@ -180,7 +180,7 @@ library
180180 import: lib-options, test-dependencies
181181 hs-source-dirs: lib
182182 exposed-modules: Streamly.Test.Common
183− if !flag(use-streamly-core) && impl(ghc < 9.4.5)
183+ if !flag(use-streamly-core)
184184 exposed-modules: Streamly.Test.Prelude.Common
185185 if flag(limit-build-mem)
186186 ghc-options: +RTS -M1500M -RTS
@@ -386,7 +386,7 @@ test-suite Prelude
386386 type: exitcode-stdio-1.0
387387 main-is: Streamly/Test/Prelude.hs
388388 ghc-options: -main-is Streamly.Test.Prelude.main
389− if flag(use-streamly-core) || impl(ghc >= 9.6)
389+ if flag(use-streamly-core)
390390 buildable: False
391391
392392test-suite Prelude.Ahead
@@ -394,7 +394,7 @@ test-suite Prelude.Ahead
394394 type: exitcode-stdio-1.0
395395 main-is: Streamly/Test/Prelude/Ahead.hs
396396 ghc-options: -main-is Streamly.Test.Prelude.Ahead.main
397− if flag(use-streamly-core) || impl(ghc >= 9.6)
397+ if flag(use-streamly-core)
398398 buildable: False
399399
400400test-suite Prelude.Async
@@ -402,7 +402,7 @@ test-suite Prelude.Async
402402 type: exitcode-stdio-1.0
403403 main-is: Streamly/Test/Prelude/Async.hs
404404 ghc-options: -main-is Streamly.Test.Prelude.Async.main
405− if flag(use-streamly-core) || impl(ghc >= 9.6)
405+ if flag(use-streamly-core)
406406 buildable: False
407407
408408test-suite Data.Stream.Concurrent
@@ -420,7 +420,7 @@ test-suite Prelude.Concurrent
420420 ghc-options: -main-is Streamly.Test.Prelude.Concurrent.main
421421 if flag(limit-build-mem)
422422 ghc-options: +RTS -M2000M -RTS
423− if flag(use-streamly-core) || impl(ghc >= 9.6)
423+ if flag(use-streamly-core)
424424 buildable: False
425425
426426test-suite Prelude.Fold
@@ -428,7 +428,7 @@ test-suite Prelude.Fold
428428 type: exitcode-stdio-1.0
429429 main-is: Streamly/Test/Prelude/Fold.hs
430430 ghc-options: -main-is Streamly.Test.Prelude.Fold.main
431− if flag(use-streamly-core) || impl(ghc >= 9.6)
431+ if flag(use-streamly-core)
432432 buildable: False
433433
434434test-suite Prelude.Parallel
@@ -436,7 +436,7 @@ test-suite Prelude.Parallel
436436 type: exitcode-stdio-1.0
437437 main-is: Streamly/Test/Prelude/Parallel.hs
438438 ghc-options: -main-is Streamly.Test.Prelude.Parallel.main
439− if flag(use-streamly-core) || impl(ghc >= 9.6)
439+ if flag(use-streamly-core)
440440 buildable: False
441441
442442test-suite Prelude.Rate
@@ -458,14 +458,14 @@ test-suite Prelude.Serial
458458 ghc-options: -main-is Streamly.Test.Prelude.Serial.main
459459 if flag(limit-build-mem)
460460 ghc-options: +RTS -M1500M -RTS
461− if flag(use-streamly-core) || impl(ghc >= 9.6)
461+ if flag(use-streamly-core)
462462 buildable: False
463463
464464test-suite Prelude.Top
465465 import: test-options
466466 type: exitcode-stdio-1.0
467467 main-is: Streamly/Test/Prelude/Top.hs
468− if flag(use-streamly-core) || impl(ghc >= 9.6)
468+ if flag(use-streamly-core)
469469 buildable: False
470470
471471test-suite Prelude.WAsync
@@ -473,7 +473,7 @@ test-suite Prelude.WAsync
473473 type: exitcode-stdio-1.0
474474 main-is: Streamly/Test/Prelude/WAsync.hs
475475 ghc-options: -main-is Streamly.Test.Prelude.WAsync.main
476− if flag(use-streamly-core) || impl(ghc >= 9.6)
476+ if flag(use-streamly-core)
477477 buildable: False
478478
479479test-suite Prelude.WSerial
@@ -481,7 +481,7 @@ test-suite Prelude.WSerial
481481 type: exitcode-stdio-1.0
482482 main-is: Streamly/Test/Prelude/WSerial.hs
483483 ghc-options: -main-is Streamly.Test.Prelude.WSerial.main
484− if flag(use-streamly-core) || impl(ghc >= 9.6)
484+ if flag(use-streamly-core)
485485 buildable: False
486486
487487test-suite Prelude.ZipAsync
@@ -491,7 +491,7 @@ test-suite Prelude.ZipAsync
491491 ghc-options: -main-is Streamly.Test.Prelude.ZipAsync.main
492492 if flag(limit-build-mem)
493493 ghc-options: +RTS -M750M -RTS
494− if flag(use-streamly-core) || impl(ghc >= 9.6)
494+ if flag(use-streamly-core)
495495 buildable: False
496496
497497test-suite Prelude.ZipSerial
@@ -499,7 +499,7 @@ test-suite Prelude.ZipSerial
499499 type: exitcode-stdio-1.0
500500 main-is: Streamly/Test/Prelude/ZipSerial.hs
501501 ghc-options: -main-is Streamly.Test.Prelude.ZipSerial.main
502− if flag(use-streamly-core) || impl(ghc >= 9.6)
502+ if flag(use-streamly-core)
503503 buildable: False
504504
505505test-suite Unicode.Stream