Skip to content
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

Embed vs Final #476

Open
greydot opened this issue Feb 13, 2023 · 2 comments
Open

Embed vs Final #476

greydot opened this issue Feb 13, 2023 · 2 comments

Comments

@greydot
Copy link

greydot commented Feb 13, 2023

Hello!

With the recent removal of withLowerToIO and resourceToIO, I've been left wondering. Is it correct to assume that polysemy is moving in the direction of removing Embed effect completely? As of right now, many things become impossible in polysemy 1.9 as opposed to version 1.7.

@KingoftheHomeless
Copy link
Collaborator

KingoftheHomeless commented Feb 13, 2023

Embed will stay -- it's less powerful than Final, but that makes it more flexible to interpret. Compare runEmbedded to finalToFinal.

withLowerToIO, resourceToIO, and asyncToIO were based on a horrific, horrific hack that abused thread forking and communication via MVars in order to work, and often didn't work. With respect to Sandy, withLowerToIO was an abomination that should never have existed.

As of right now, many things become impossible in polysemy 1.9 as opposed to version 1.7.

What things? Final's the safe, sane replacement of the old usages of withLowerToIO. Why can't you use resourceToIOFinal instead of resourceToIO, or withWeavingToFinal/withStrategicToFinal instead of withLowerToIO? Sure, on the surface they're more difficult to use and less flexible than withLowerToIO, but the flexibility and simplicity of withLowerToIO was a lie -- withLowerToIO is horribly unsafe and unsound, and the library ever offering it was a mistake.

Admittedly, withStrategicToFinal's interface is pretty bad. In the WIP core rewrite we're gonna replace its current interface with an interface that's closer to MonadBaseControl in use.

@greydot
Copy link
Author

greydot commented Feb 13, 2023

Final's the safe, sane replacement of the old usages of withLowerToIO. Why can't you use resourceToIOFinal instead of resourceToIO, or withWeavingToFinal/withStrategicToFinal instead of withLowerToIO? Sure, on the surface they're more difficult to use and less flexible than withLowerToIO, but the flexibility and simplicity of withLowerToIO was a lie -- withLowerToIO is horribly unsafe and unsound, and the library ever offering it was a mistake.

Mostly, the lack of (easy to find) examples. Another problem is the need to combine Embed and Final in the same effects stack in the presence of third-party libraries, although this can be mitigated with embedToFinal, I'd still to only have to deal with one of them.

Admittedly, withStrategicToFinal's interface is pretty bad. In the WIP core rewrite we're gonna replace its current interface with an interface that's closer to MonadBaseControl in use.

I would love to see that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants