On Thu, 18 Sep 2003, Ross Paterson wrote:
The arguments being made here can all be found in the recursive monad bindings papers and Levent's thesis.
I don't remember anything about finding smaller binding groups in the mdo paper. I don't think I've read Levent's thesis.
On Wed, Sep 17, 2003 at 11:41:24AM -0700, Brandon Michael Moore wrote:
In any case, I don't see the need for explicit rec groups. Can't GHC just find the strongly connected components like it already does with let bindings?
That's what GHC and Hugs do now for mdo (actually segments rather than components, because actions can't be rearranged).
Don't the laws for loop and mfix justify the transformation?
The loop axioms do, but Levent didn't assume right tightening, which corresponds to moving bindings down from a rec, because monads like exceptions don't satisfy it. The same would go for a loop defined on an exception arrow. And that's the biggest problem with implicit segmentation: you need to understand what it does to work out the meaning of your program. Again there's an example in those papers and Levent's thesis.
I expected any problems would be like that. I remember hearing about a fixpoint operator for the continuation monad that satisfied all the laws but right tightening. Well, this would fall under "If it really turns out to be frequently necessary".
BTW, in GHC 6.2 with the -fglasgow-exts -farrows flags, you will be able to use either mdo or do...rec for monads and for arrows, as an experiment. (Maybe "rec" wasn't such a great keyword to take from the identifier space.)
When can we expect 6.2? Brandon