-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
pureEval vs a typeclass #1150
Comments
In case it's of any interest, today on Gitter @tpolecat had me questioning |
What does "true laziness support" mean? Would it be a guarantee that the |
@tpolecat yeah, I think that's right. You could test that by using a Is it a "real abstraction"? I don't know, but I know some That said, I am wondering if we just want to have |
Another concern I ran into yesterday was that The specific situation I ran into is writing an Some discussion on Gitter happened here: https://gitter.im/typelevel/cats?at=5796a24600c8ebdd0e239982 |
This probably resolves typelevel#1150, though it doesn't provide an alternative type class as was brought up there. @adelbertc has [gotten tripped up](typelevel#1150 (comment)) by `pureEval` defaulting to a call to `pure` with `.value` called on the `Eval`. @johnynek has also [questioned](typelevel#1150 (comment)) `pureEval` being directly on `Applicative`. @tpolecat has [raised concerns](https://gitter.im/typelevel/cats?at=5794dc4c1b9de56c0edd887a) that `pureEval` looks like it might exist as a way to inject side effects into a type, but that it doesn't actually make any claims about execution semantics or value retention, so it can't be relied upon to do this. I think that there could be an argument for having an instantiation method for a side-effect-y type (like a `Task`) that takes an `Eval[A]` and produces an instance that will repeat the computation given `Always`, memoize the value given `Later`, etc. However, I don't think that @tpolecat necessarily agrees with me, and I think that even _if_ this is a reasonable thing to do, `Applicative` probably isn't the place for it. Since several people have questioned `pureEval`, it was entirely untested, and I haven't heard any one argue for it staying, I'm inclined to remove it. If someone has a compelling example of when a non-strict argument can be useful for `pure`, then I may be convinced. But even then we should clearly document what behavior can be expected of `pureEval`.
Apologies if this was discussed, but I wonder why
pureEval
was added toApplicative
vs something like:with the law that
Eq[F[A]].equiv(pureEval(e), pure(e.value))
Seems like making that always present but by default forcing
.value
it removes the ability of the caller ofpureEval
to know ifvalue
is called immediately or not. With a new type, it would not be optional laziness, it would advertise true laziness support.Maybe this is not a super meaningful distinction (unlike
tailRecM
which can be implemented in a non-tailrecursive way with flatMap), but still it seemed easy enough to signal at the type level.The text was updated successfully, but these errors were encountered: