Closed Kyuuhachi closed 4 years ago
Nope.
Due to fundamental issues with the weave
abstraction that the library is built on (see Effect Handlers In Scope), a well-behaved Coroutine
effect is impossible to make in Polysemy
.
To be technical, CoroutineT
doesn't have a well-defined functorial state; i.e. it's not a MonadTransControl
, and weave
basically requires every carrier to be MonadTransControl
.
The solution would be to ditch weave
, but that's easier said than done; although I am working on it. The result would probably be too different to fall under the polysemy name, though.
See Polysemy issue #264 for a failed attempt at this.
I noticed that
pogoStick
from monad-coroutine is very similar (type-wise) tointerpret
, which got me thinking: Would it be possible to implement an effect behaving similarly to that Coroutine transformer? As an example, I think this could probably be used for connecting anOutput
into anInput
, without having to manually write either as a state machine, as is necessary if doing the same withinterpret
. (I'm not sure what would happen if either ends before the other though.)