Currently, ado-notation allows the following:
ado x <- f
y <- g x
in x + y
In this example, _x_ is a free variable of the ado expression.
While not problematic in and of itself, this makes a future change to allow monadic bind in an ado expression a backwards incompatible change.
In GHC, applicative do allows binds, and will add a monad constraint. But it will only use bind instead of ap when necessary.
Allowing monadic binds would be desirable for Haxl-like computations.
We still want to keep the ado鈥搃n syntax, rather than transforming all do expressions, because of the strictness of ap.
That sounds reasonable to me.
to allow monadic bind in an ado expression
Isn't that what do is for?
I would really like to keep do and ado separate.
I think there鈥檚 a strong argument to be made in favour of this even if we are keeping do and ado separate*, which is that it鈥檚 confusing. For a type which has lawful Applicative and Monad instances, I feel that changing a do to an ado (or vice versa) should have no observable effect.
In a similar vein I鈥檇 quite like to improve the error when code such as the above results in an unknown name error, perhaps with a hint reminding you that applicative do notation cannot refer to earlier bindings, and that you may want to consider using regular do instead.
* I am also very much in favour of keeping do and ado separate.
Most helpful comment
Isn't that what
dois for?I would really like to keep
doandadoseparate.