Thank you for your smart and interesting implementation, which uses context abstraction, Project Loom's coroutines and no CPS transformation.
However, there is a point which concerns me.
Some type of monads, such as list monad, does not work well, since a coroutine can simulate only an "affine" delimited continuation, which can be used at most once.
An example using Scalaz follows:
val list: List[Int] = reify [List] in {
val l = List(1, 2, 3).flatMap(x => List(x + 5)).reflect
val k = List(2, 3, 4).reflect
l * k
}
println(list)
[error] (run-main-0) java.lang.IllegalStateException: Continuation terminated
[error] java.lang.IllegalStateException: Continuation terminated
[error] at java.base/java.lang.Continuation.run(Continuation.java:286)
[error] at monadic.Coroutine.resume(Coroutine.scala:19)
[error] at monadic.Monadic.step$1(Monadic.scala:49)
[error] at monadic.Monadic.run$2$$anonfun$1(Monadic.scala:61)
[error] at monadic.ScalazMonadic.sequence$$anonfun$2$$anonfun$1(examples.scala:14)
...
Would you write this limitation in README?
Thank you.
Thank you for your smart and interesting implementation, which uses context abstraction, Project Loom's coroutines and no CPS transformation.
However, there is a point which concerns me. Some type of monads, such as list monad, does not work well, since a coroutine can simulate only an "affine" delimited continuation, which can be used at most once.
An example using Scalaz follows:
Would you write this limitation in README? Thank you.