-
Notifications
You must be signed in to change notification settings - Fork 536
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
Bike shedding #1
Comments
If we have |
Agreed.
https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/ApplicativeError.scala#L46
Why?
I too am unsure of how I feel about it. Happy to remove. The guiding principle was basically "things from
👍
Oh, I forgot about that! I'll look into the differences.
Eh… There's no namespace conflict, since it's being called on an Do you have a better name in mind though? I'm not married to
Yep.
I wanted to steer clear of any concurrency support in Maybe the "strict concurrency avoidance" plan is a bad one, I'm not sure. I wanted to do that both to avoid stepping on fs2/Monix, and because I thought the separation of concerns could be beneficial. |
No strong opinions on I can live without final def async(implicit ec: ExecutionContext): IO[A] = IO.async { cb =>
ec.execute(new Runnable { def run = unsafeRunAsync(cb) })
} |
I'm ok with that, though the name seems a bit weird. How does |
Agreed on name being weird. I'm fine with either of your suggestions. Are you okay with both |
I have an |
Oh right, lol. The constructor variant is basically |
Eh that's fair. OK I'm happy with just |
Alrighty. :-) So we're loosening the "no concurrency" restriction to "no concurrency, but thread pool manipulation isn't really concurrency, so it's ok," which actually seems pretty reasonable to me. |
So to summarize, we've got the following actions:
Thoughts on my |
What would I guess it would just be: F.runAsync(signal.set(d))(_ => IO(running.set(false))).unsafeRunSync |
Yep. Conceptually here, the typeclass is "imbuing" |
@mpilquist Implementing /**
* Shifts the computation of any prefix contiguous synchronous actions into the implicitly
* specified `ExecutionContext`. Asynchronous actions and continuations will be unshifted
* and will remain on whatever thread they are associated with. This should be used if
* you want to evaluate a given `IO` action on a specific thread pool when it is eventually
* run.
*/
final def shiftPrefix(implicit EC: ExecutionContext): IO[A] = {
IO async { cb =>
EC.execute(new Runnable {
def run() = self.unsafeRunAsync(cb)
})
}
}
/**
* Shifts the continuation of the action into the implicitly specified `ExecutionContext`.
* The thread pool association will be observed in any actions which are flatMapped onto
* the result of this function. That is to say, the *continuation* of the `IO`. All of
* the effects within the current `IO` will retain their pre-existing thread affinities,
* if any.
*
* This function is most useful on asynchronous actions which require thread-shifting back
* onto some other thread pool (e.g. off of an event dispatch thread).
*/
final def shiftSuffix(implicit EC: ExecutionContext): IO[A] = {
attempt.flatMap { e =>
IO async { (cb: Either[Throwable, A] => Unit) =>
EC.execute(new Runnable {
def run() = cb(e)
})
}
}
} |
Closing this now since I've implemented all the things. Please feel free to open more for other desired changes! |
Bracket changes proposal
…rialization, switched to Serializable laws
cats.effect.Attempt
alias. It's currentlyprivate[effect]
which is confusing for folks reading the code. We could make it public but I don't think an effect library should provide a minor syntax convenience like this.Catchable
withMonadError
means we lose this method:This is commonly used in FS2. I suppose the right thing to do here is PRing this method to MonadError in cats.
unsafeRunAsync
somewhere -- either onEffect
or perhaps on a subtype ofEffect
if we want to limit where it might be invoked via parametric polymorphism.StdIO
-- seems like a bucket of random things for which there's no guiding principle on deciding what should be added. E.g., how aboutrandomUUID: IO[UUID]
?IO
from asealed trait
to asealed abstract class
to help with binary compat issues in the future.scala.util.control.NonFatal
instead offs2.util.NonFatal
. I'm fine with this but both Paul and Daniel supported using a custom notion ofNonFatal
that didn't catch ControlException and some others.IO#ensuring
given theensuring
fromPredef
Task.delay
is nowIO.apply
andTask.apply
doesn't exist, right?The text was updated successfully, but these errors were encountered: