llvm
llvm copied to clipboard
Can MonadFix help eliminate need for newX/defineX split?
I'm just starting to explore the module, so not sure it makes sense in this case, but I know it was the answer for me when I encountered a similar API design problem. GHCs DoRec
extension lets you do things like this for monads with a MonadFix
instance, like IO
:
do rec a <- somethingWith b
b <- somethingWith a
c <- foo c
etc
Yes, I believe so. I'm not much of a fan of the split either... any chance you could put together a patch?
I added derived MonadFix
instances in 0b042455cdab68b92e12db6485a8bb4a436953b8... if you have a chance to try them out that'd be great.
Can someone explain, what the problem is? MonadFix on IO sounds strange to me.
Sorry to be out of touch on this! I'd like to try my hand at this but may not be able to make the time for it in the very near future. Im also not a real user od this lib yet.
In the meantime a concrete example of the same kind of thing is in a
package I have called simple-actors. Where monadfix eliminates the need for
separate "create mailbox" and "run on mailbox" and allows spawn
to do
both, leaving us with a simpler API that we can't use incorrectly (e.g.
running two different actors on the same mailbox or "mailbox token" would
be wrong)
I added derived MonadFix instances in 0b04245https://github.com/bos/llvm/commit/0b042455cdab68b92e12db6485a8bb4a436953b8... if you have a chance to try them out that'd be great.
— Reply to this email directly or view it on GitHubhttps://github.com/bos/llvm/issues/41#issuecomment-17921478 .