Re: [Caml-list] [Camlp4][trivial ?] Anonymous bind (for monads)

Julien Moutinho
2007-07-31T17:50:18Z

On Tue, Jul 31, 2007 at 06:55:05PM +0200, Gabriel Kerneis wrote:
> EXTEND Gram
> expr: LEVEL "top"
> [[ t=expr; "foo"; f=expr ->
> <:expr<
> Lwt.bind $t$ (fun () -> $f$)
> >>]];
> END
> end
> [...]
> But if I change "foo" to ">>" (which is the usual way to write an
> anonymous bind for monads), it doesn't work anymore. I first thought the
> reason was that ">>" is also the symbol for closing a quotation, but
> trying "++" instead proved useless as well.
>
> I'm certainly not a camlp4 guru so... what am I missing?

My guess is that the first [t=expr] swallows the ">>".
You can try "->" or "|" against which [expr] does not match,
but I think it is not advisable to use them in a bigger program.

However, I'm sure that Mr.Pouillard will be happy to enlight us on how to use ">>".

HTH a little.