-
Notifications
You must be signed in to change notification settings - Fork 17
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
Instantiating Class which requires a TVar #363
Comments
Hi Karl, this is a great question! Firstly thanks for using cats-stm! :) And for trying to upgrade so quickly to 0.11.0 - that was impressively fast! The answer to this is somewhat long but I'll do my best! A bit of historySo in class TVar[F[_], A] {
val state: Ref[F, A]
} additionally we have some global state trait STM[F[_]] {
val globalState: Ref[F, STMState]
} This kind of sucks. So instead we made trait STM[F[_]] {
val globalState: Ref[F, STMState]
//Note that TVar no longer has to be parameterized on F[_]
class TVar[A] {
val state: TVar[F, A]
}
} Structuring applications with 0.11.0As def foo[F[_], A](stm: STM[F])(tvar: stm.TVar[A] = ??? Class parameters are actually a quite tricky case as you can't have multiple parameter blocks. If TLDRThere is not a way to reference And please do upgrade once I've fixed the issues! I know that I hope that answers some of your questions at least. Do let me know if you have more questions! |
Hello
Having upgraded from 0.8.0 to 0.11.0 I have what is either a question or an issue (I am unsure but raising it as an issue to hopefully at least get an answer).
I have a class that requires a TVar to be passed in at instantiation which is posing an import based issue.
class MyClass(val stuff: TVar[String]) { ... }
Previously (0.8.0) I could have an "import io.github.timwspence.cats.stm.TVar" at the top of my class, this no longer works and from the examples the approach is something akin to
but this does not work outside of a class or object?
Is there a way to reference the TVar class without having to instatiate the Stm Runtime?
Please advise if this is a legitimate issue, a misuse issue or just a misunderstanding?
Karl
The text was updated successfully, but these errors were encountered: