-
Notifications
You must be signed in to change notification settings - Fork 520
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
Make Sync extend Defer #296
Conversation
# Conflicts: # build.sbt
Adding a new supertype to the hierarchy will very likely break binary compatability on 2.11, so be sure to add those MiMa exceptions :) |
Should we make |
No, actually that's a bad idea. |
@LukaJCB Thanks, hopefully it will be ok now - is there a way to run it locally for all supported versions? |
Codecov Report
@@ Coverage Diff @@
## master #296 +/- ##
==========================================
- Coverage 86.97% 86.81% -0.16%
==========================================
Files 64 64
Lines 1797 1798 +1
Branches 186 187 +1
==========================================
- Hits 1563 1561 -2
- Misses 234 237 +3 |
@Avasil, you can run |
@@ -25,8 +25,8 @@ import cats.syntax.all._ | |||
* A monad that can suspend the execution of side effects | |||
* in the `F[_]` context. | |||
*/ | |||
@typeclass | |||
trait Sync[F[_]] extends Bracket[F, Throwable] { | |||
@typeclass(excludeParents = List("Defer")) |
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.
Why is excludeParents
necessary here?
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.
Compiler was complaining with type AllOps is not a member of object cats.Defer
, I've got fix from typelevel/simulacrum#38
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.
Thanks for taking this.
* Alias for `suspend` that suspends the evaluation of | ||
* an `F` reference and implements `cats.Defer` typeclass. | ||
*/ | ||
override def defer[A](fa: => F[A]): F[A] = suspend(fa) |
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.
IMO we should make this a final
, as we should never allow defer
to not be an alias of suspend
.
It also makes it easier for people implementing Sync
when overriding methods for performance reasons, as defer
will no longer be shown by the IDE.
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.
That makes sense. 👍
I hate to suggest another change as we're trying to stabilize, but given that it's a final alias, what if we retired the name |
@rossabaker I don't like this idea... If we retire I don't know why you should use |
I'm in favor of deleting |
My 2¢, as I already expressed when we talked about the terminology of suspend:
Keeping
Also I think In other words we can pretend that |
Btw, if you have a problem with the naming, just as we have But that doesn't actually solve anything imo. |
Do you have an example of this? Doesn't make sense to me (this is just for curiosity, not for the sake of arguing in this thread :) ). Computations are already all suspended in Haskell,
Well, I think it says more about the broken recursion model in Scala tbh.
I don't think this argument is that strong, it's the same thing with Eval, or with side effects in |
Not all computations are suspended in Haskell, Haskell isn't actually lazy and its non-strict model can break in non-obvious ways. Here's an example: https://twitter.com/pasiphae_goals/status/966730065345241089
No, I don't think you can blame this one on Scala.
For |
Haskell is non-strict which means you can't have a valid implementation of it that works like if it was strict (so, not suspended). The only time this should break in the way you mention in when doing FFI, and indeed the example you mention fits in that category, but that makes sense since the code you are evaluating is not haskell code and doesn't fit Haskell's execution model.
Not on Scala, no, that's harsh, but definitely on strict languages on the JVM. If your recursion model can't express infinite recursion, then it's broken.
That's a good point :) But for example scalaz has |
If we really want to keep effects in suspend I think the PR is good as is. |
# Conflicts: # build.sbt
Guys, if you want to remove We have |
Fixes #286