Laws questions #3931
-
A few questions (mostly) about laws:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
That's correct. This is an important difference because However we have
For
Yes, that is my preference.
I wouldn't oppose rewriting those to |
Beta Was this translation helpful? Give feedback.
-
In 2.x there used to be a lot of laws for stack safety: Maybe we should create some of these in 3.x too? Or is the "new" way to useDefer instead of relying on a stack-safe flatMap ?
|
Beta Was this translation helpful? Give feedback.
-
I can add some color here to what's already been said! Regarding Regarding I don't really find Regarding The general problem here is that "stack" as a rule is an untracked side effect, similar to how memory is an untracked side effect. This is unprincipled in a sense, but it's also pragmatic since there's simply no way we could track memory or stack allocation with that level of rigor within the bounds of the Scala language (or Haskell, for that matter). Since it's an untracked side-effect, we end up in this awkward spot where we have to make assertions about a thing without really encoding those assertions in any particularly strong way at the type level, which is obviously the opposite of how we normally work. If you think about it, we make a very similar set of implicit assertions around |
Beta Was this translation helpful? Give feedback.
Oh, indeed it does! In that case, I agree then that seems fine.
Yes, in a handful places where we actually want
defer
instead we assume that we have aStackSafeMonad
. Also some occurrences in FS2.cats-effect/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala
Line 294 in 8905b98
cats-effect/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala
Lines 419 to 420 in 8905b98