-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow using unliftio-core instead of monad-control #1485
Allow using unliftio-core instead of monad-control #1485
Conversation
@harendra-kumar if you are interested, please take a look. I haven't done anything with the tests or benchmarks, just made it compile. |
@@ -31,9 +31,12 @@ import Control.Monad.Trans.Control (MonadBaseControl, control, StM) | |||
-- /Since: 0.1.0 ("Streamly")/ | |||
-- | |||
-- @since 0.8.0 | |||
type MonadAsync m = (MonadIO m, MonadBaseControl IO m, MonadThrow m) | |||
type MonadAsync m = (MonadUnliftIO m, MonadThrow m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall change looks pretty simple. I am wondering if we can restrict the abstractions to this file, and be able to switch between monad-control and unliftIO by just using a CPP macro. For example, we can define:
#ifdef UNLIFT_IO
type MonadControlIO m = MonadUnliftIO m
#else
type MonadControlIO m = (MonadIO m, MonadBaseControl IO m)
#endif
type MonadAsync m = (MonadControlIO m, MonadThrow m)
We can have similar definitions for RunInIO, runInIO and withRunIO (it will be control
in case of monad-control).
With these changes we should only be importing this file everywhere rather than importing monad-control or unliftio. And then we can commit this change easily because there are no real changes to the code, its just a refactor to allow unliftio.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, sounds easy enough. I should be able to do that this weekend, if not sooner.
I merged monad-base branch to master. You can base it on master now. |
259f590
to
b92f2f7
Compare
b92f2f7
to
26d66fb
Compare
@harendra-kumar I rebased onto master and added the CPP flag handling to swap between unliftio-core and monad-control. Streamly.Internal.Control.Concurrent could be reorganized and could use some better docs, but I think this is the general approach you were looking for. Thoughts? |
26d66fb
to
12d5c6e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and clean @andremarianiello . Thank you.
eba9baa
to
6ab99ce
Compare
CIs look good. Merging it. Thanks @andremarianiello |
Uhm... cabal flags should never affect external API. Cabal currently does not allow setting flags on dependent packages from within a That said, I too prefer MonadUnliftIO. |
This is an experimental feature. |
That isn't quite the point. Flags that cause public API to change can make packages on hackage become unbuildable. |
How does that happen? All flags may not be for end user consumption. We may have private build flags in the package e.g. we have flags to use for dev testing and benchmarking, some of these flags may alter the APIs or behavior of the package. It would be very restrictive if flags are only meant for API users' consumption. |
type MonadAsync m = (MonadUnliftIO m, MonadThrow m) vs type MonadAsync m = (MonadIO m, MonadBaseControl IO m, MonadThrow m) MonadAsync is exported from Streamly.Prelude. Now, a downstream user may use the flag
The package That aside, I believe streamly should switch unconditionally to In my own codebase, I'm already unable to use |
That is the whole point of confusion, this flag is experimental and for private use only, it is not a released feature, therefore, you are not supposed to use this flag in a package and upload that package to hackage. For general use only monad-control is supported. This was implemented as a proof of concept to know what all needs to be changed if we have to change from monad-control to unliftio. It can be used in private projects though. |
I see, is there an ETA on when streamly switches to unliftio? |
See this #395 (comment) to use resourcet. I am not sure about the ETA, we are separating the serial streams from concurrent ones in a separate package possibly without dependency on monad-control. Will think about this after that. |
I'm not sure I want to do that since snoyman's blog post indicated that the old
|
Just a little experiment to see what it would look like if monad-control was replaced