caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Camlp4][trivial ?] Anonymous bind (for monads)
@ 2007-07-31 16:55 Gabriel Kerneis
  2007-07-31 17:02 ` [Caml-list] " Gabriel Kerneis
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gabriel Kerneis @ 2007-07-31 16:55 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1285 bytes --]

Hello,

I've got a little problem with camlp4. The following works perfectly
well :
#####################################################################
~/ocaml/camlp4% cat pa_bind.ml
module Id = struct
  let name = "pa_bind"
  let version = "$Id:$"
end

module Example (Syntax : Camlp4.Sig.Camlp4Syntax) = struct
 include Syntax

 EXTEND Gram
 expr: LEVEL "top"
   [[ t=expr; "foo"; f=expr ->
        <:expr<
            Lwt.bind $t$ (fun () -> $f$)   
        >>]];  
 END
end

module M = Camlp4.Register.OCamlSyntaxExtension(Id)(Example)

~/ocaml/camlp4% ocamlc -c -pp camlp4of -I +camlp4 pa_bind.ml 

~/ocaml/camlp4% cat test_bind.ml 
let r = (Lwt_unix.sleep 5) foo (print_endline "42")

~/ocaml/camlp4% camlp4of -parser pa_bind.cmo test_bind.ml 
let r = Lwt.bind (Lwt_unix.sleep 5) (fun () -> print_endline "42")

#####################################################################

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?

Thanks a lot.

Regards,
-- 
Gabriel

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-09 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-31 16:55 [Camlp4][trivial ?] Anonymous bind (for monads) Gabriel Kerneis
2007-07-31 17:02 ` [Caml-list] " Gabriel Kerneis
2007-07-31 17:50 ` Julien Moutinho
2007-08-09 18:29 ` Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).