polysemy-research / polysemy-zoo

:monkey::panda_face: Experimental, user-contributed effects and interpreters for polysemy
BSD 3-Clause "New" or "Revised" License
70 stars 21 forks source link

Coroutine/trampoline effect #64

Closed Kyuuhachi closed 4 years ago

Kyuuhachi commented 4 years ago

I noticed that pogoStick from monad-coroutine is very similar (type-wise) to interpret, 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 an Output into an Input, without having to manually write either as a state machine, as is necessary if doing the same with interpret. (I'm not sure what would happen if either ends before the other though.)

KingoftheHomeless commented 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.

KingoftheHomeless commented 4 years ago

See Polysemy issue #264 for a failed attempt at this.