-
I have a stateful non-deterministic monad originally defined like this trait Trying[State, +Result] {
def apply(state: State): Vector[Res[State, Result]]
}
final class CpsMonadTrying[State] extends CpsMonad[[X] =>> Trying[State, X]] with CpsMonadContext[[X] =>> Trying[State, X]] I can use it with async await fine. type Trying[State, +Result] = State => Vector[Res[State, Result]] Then I got complains When I am writing this CpsMonad I don't know what is CpsMonadContext for I just make up something to make it compile. I can't find any code or documents about CpsMonadContext to make myself understand final class CpsMonadTrying[State] extends CpsMonad[[X] =>> Trying[State, X]] with CpsMonadContext[[X] =>> Trying[State, X]] {
...
override def monad: CpsMonad[WF] = this
override type Context = this.type
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
About CpsMonadContext - look at this section: https://rssh.github.io/dotty-cps-async/MonadContexts.html
Full example can be found ... |
Beta Was this translation helpful? Give feedback.
-
Also look at the logic module, https://github.com/rssh/dotty-cps-async/tree/master/logic https://github.com/rssh/dotty-cps-async/tree/master/logic/shared/src/main/scala/cps/monads/logic |
Beta Was this translation helpful? Give feedback.
About CpsMonadContext - look at this section: https://rssh.github.io/dotty-cps-async/MonadContexts.html
If you have no runtime infrastructure around context, then
Full example can be found ...
https://github.com/rssh/dotty-cps-async/blob/master/shared/src/test/scala/cpstest/CpsContT.scala
(but it's too long, searching shorter ...