llvm icon indicating copy to clipboard operation
llvm copied to clipboard

Can MonadFix help eliminate need for newX/defineX split?

Open jberryman opened this issue 12 years ago • 4 comments

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

jberryman avatar Nov 07 '12 23:11 jberryman

Yes, I believe so. I'm not much of a fan of the split either... any chance you could put together a patch?

NathanHowell avatar May 07 '13 05:05 NathanHowell

I added derived MonadFix instances in 0b042455cdab68b92e12db6485a8bb4a436953b8... if you have a chance to try them out that'd be great.

NathanHowell avatar May 15 '13 05:05 NathanHowell

Can someone explain, what the problem is? MonadFix on IO sounds strange to me.

amigalemming avatar May 22 '13 08:05 amigalemming

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 .

jberryman avatar May 22 '13 22:05 jberryman