* camlp4 infix let
@ 2010-04-07 19:05 Jacques Le Normand
2010-04-07 19:45 ` [Caml-list] " Jérémie Dimino
0 siblings, 1 reply; 3+ messages in thread
From: Jacques Le Normand @ 2010-04-07 19:05 UTC (permalink / raw)
To: caml-list caml-list
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
Dear List,
I'm writing a camlp4 syntax extension and I'd like to write
<:expr< let ( >>= ) = Bar.( >>= ) in 5 >>
but camlp4 complains:
While expanding quotation "expr" in a position of "expr":
Parse error: ")" or [ipatt] expected after "(" (in [ipatt])
yet it seems to be valid revised syntax. Does anyone have any ideas?
[-- Attachment #2: Type: text/html, Size: 454 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] camlp4 infix let
2010-04-07 19:05 camlp4 infix let Jacques Le Normand
@ 2010-04-07 19:45 ` Jérémie Dimino
2010-04-07 20:24 ` Martin Jambon
0 siblings, 1 reply; 3+ messages in thread
From: Jérémie Dimino @ 2010-04-07 19:45 UTC (permalink / raw)
To: Jacques Le Normand; +Cc: caml-list caml-list
Hi,
Le mercredi 07 avril 2010 à 15:05 -0400, Jacques Le Normand a écrit :
> Dear List,
> I'm writing a camlp4 syntax extension and I'd like to write
>
> <:expr< let ( >>= ) = Bar.( >>= ) in 5 >>
>
> but camlp4 complains:
>
> While expanding quotation "expr" in a position of "expr":
> Parse error: ")" or [ipatt] expected after "(" (in [ipatt])
>
> yet it seems to be valid revised syntax. Does anyone have any ideas?
It is because the ">>" of the ">>=" operator is detected as the end of
the camlp4 quotation. You can try something like that:
let operator = ">>=" in <:expr< let ($lid:operator$) = Bar.($lid:operator$) in 5 >>
Cheers,
Jérémie
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] camlp4 infix let
2010-04-07 19:45 ` [Caml-list] " Jérémie Dimino
@ 2010-04-07 20:24 ` Martin Jambon
0 siblings, 0 replies; 3+ messages in thread
From: Martin Jambon @ 2010-04-07 20:24 UTC (permalink / raw)
To: Jérémie Dimino; +Cc: Jacques Le Normand, caml-list caml-list
Jérémie Dimino wrote:
> Hi,
>
> Le mercredi 07 avril 2010 à 15:05 -0400, Jacques Le Normand a écrit :
>> Dear List,
>> I'm writing a camlp4 syntax extension and I'd like to write
>>
>> <:expr< let ( >>= ) = Bar.( >>= ) in 5 >>
>> but camlp4 complains:
>>
>> While expanding quotation "expr" in a position of "expr":
>> Parse error: ")" or [ipatt] expected after "(" (in [ipatt])
>>
>> yet it seems to be valid revised syntax. Does anyone have any ideas?
The revised syntax of the old camlp4 or camlp5 requires a backslash in front
of the operator instead of parentheses:
$ cat foo.ml
let \>>= = Bar.\>>= in 5 ;
$ camlp5r pr_o.cmo foo.ml
let _ = let (>>=) = Bar.(>>=) in 5
I don't know how to make it work with the new camlp4:
$ camlp4r -printer o foo.ml
File "foo.ml", line 1, characters 4-8:
Parse error: "module" or [opt_rec] expected after "let" (in [expr])
> It is because the ">>" of the ">>=" operator is detected as the end of
> the camlp4 quotation. You can try something like that:
>
> let operator = ">>=" in <:expr< let ($lid:operator$) = Bar.($lid:operator$) in 5 >>
I would add it is simpler to just avoid << and >> in any ocaml source code
unless camlp5/camlp4 is not involved.
Martin
--
http://mjambon.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-07 20:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-07 19:05 camlp4 infix let Jacques Le Normand
2010-04-07 19:45 ` [Caml-list] " Jérémie Dimino
2010-04-07 20:24 ` Martin Jambon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox