caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Most recent CVS-branch?
@ 2007-07-25 15:38 Markus Mottl
  2007-07-25 17:52 ` Camlp4: ctyp antiquotation and polymorphic type question Massimiliano Brocchini
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Markus Mottl @ 2007-07-25 15:38 UTC (permalink / raw)
  To: ocaml

Hi,

which one is actually the most recent CVS-branch for OCaml right now?
I thought it was release310, but I got a note that bug 0004349 has
been fixed in the CVS and couldn't find the patch there or in any
other branch - maybe I just overlooked it.  Is there a general naming
scheme for branches so that one can always find the most recent one
that is going to be released?  It doesn't seem to be "HEAD".

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com


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

* Camlp4: ctyp antiquotation and polymorphic type question
  2007-07-25 15:38 Most recent CVS-branch? Markus Mottl
@ 2007-07-25 17:52 ` Massimiliano Brocchini
  2007-07-26  8:28 ` [Caml-list] Most recent CVS-branch? Nicolas Pouillard
  2007-07-26 12:46 ` Camlp4: ctyp antiquotation and polymorphic type question Massimiliano Brocchini
  2 siblings, 0 replies; 5+ messages in thread
From: Massimiliano Brocchini @ 2007-07-25 17:52 UTC (permalink / raw)
  To: ocaml

Hi,

I have a type expression stored in a string (obtained by cmigrep) and I 
need to attach it to a polymorphic method definition, but I can't obtain 
what I expected... I tried two solutions but I miserably failed:

1) with the following code
    let t1 = <:ctyp<$anti:quant$>> in
    let t2 = <:ctyp<$anti:function_type$>> in
    let method_type_expanded = <:ctyp< !$t1$.$t2$ >> in
     <:class_str_item< method $x$ : $method_type_expanded$ = $expression$ >>

I get this error message:
[...] While expanding quotation "ctyp" in a position of "expr":
  Parse error: illegal begin of quotation of type

I even tried using a list instead of the first ctyp (t1) as mentioned in 
the old camlp4 3.07 manual:

    let method_type_expanded = <:ctyp< !$list:var_list$.$t2$ >> in

but it doesn't work.

2) I tried building the polymorphic methods type declaration (e.g. 'a 
'b. 'a->'b) by concatenation of strings
let method_type = (vars ^ " . " ^ function_type) in
let method_type_expanded = <:ctyp<$anti:method_type$>> in
     <:class_str_item< method $x$ : $method_type_expanded$ = $expression$ >>

compiles and works to some extent... it adds the antiquotation in the 
translated .ml file which has two problems:
- it is an unparsed string, so no compiler checks on it
- it is surrounded by $ (e.g. method foo : $ 'a. 'a list -> 'a$ = ....)

Could you please explain how to have the antiquotation correctly parsed 
by camlp4?
Am I on the wrong path? (I don't feel like writing a parser for type 
expressions :( ).

Regards,
Massimiliano Brocchini (camlp4 beginner)


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

* Re: [Caml-list] Most recent CVS-branch?
  2007-07-25 15:38 Most recent CVS-branch? Markus Mottl
  2007-07-25 17:52 ` Camlp4: ctyp antiquotation and polymorphic type question Massimiliano Brocchini
@ 2007-07-26  8:28 ` Nicolas Pouillard
  2007-07-26 12:46 ` Camlp4: ctyp antiquotation and polymorphic type question Massimiliano Brocchini
  2 siblings, 0 replies; 5+ messages in thread
From: Nicolas Pouillard @ 2007-07-26  8:28 UTC (permalink / raw)
  To: Markus Mottl; +Cc: ocaml

PR#4349 has been fixed in the release310 branch, but perhaps you
search for it to soon (there is a propagation done to the public
repository every 4 or 6 hours).

On 7/25/07, Markus Mottl <markus.mottl@gmail.com> wrote:
> Hi,
>
> which one is actually the most recent CVS-branch for OCaml right now?
> I thought it was release310, but I got a note that bug 0004349 has
> been fixed in the CVS and couldn't find the patch there or in any
> other branch - maybe I just overlooked it.  Is there a general naming
> scheme for branches so that one can always find the most recent one
> that is going to be released?  It doesn't seem to be "HEAD".
>
> Regards,
> Markus
>

-- 
Nicolas Pouillard


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

* Camlp4: ctyp antiquotation and polymorphic type question
  2007-07-25 15:38 Most recent CVS-branch? Markus Mottl
  2007-07-25 17:52 ` Camlp4: ctyp antiquotation and polymorphic type question Massimiliano Brocchini
  2007-07-26  8:28 ` [Caml-list] Most recent CVS-branch? Nicolas Pouillard
@ 2007-07-26 12:46 ` Massimiliano Brocchini
  2007-07-26 13:23   ` [Caml-list] " Nicolas Pouillard
  2 siblings, 1 reply; 5+ messages in thread
From: Massimiliano Brocchini @ 2007-07-26 12:46 UTC (permalink / raw)
  To: ocaml

Hi,

I have a type expression stored in a string (obtained by cmigrep) and I
need to attach it to a polymorphic method definition, but I can't obtain
what I expected... I tried two solutions but I miserably failed:

1) with the following code
    let t1 = <:ctyp<$anti:quant$>> in
    let t2 = <:ctyp<$anti:function_type$>> in
    let method_type_expanded = <:ctyp< !$t1$.$t2$ >> in
     <:class_str_item< method $x$ : $method_type_expanded$ = $expression$ >>

I get this error message:
[...] While expanding quotation "ctyp" in a position of "expr":
  Parse error: illegal begin of quotation of type

I even tried using a list instead of the first ctyp (t1) as mentioned in
the old camlp4 3.07 manual:

    let method_type_expanded = <:ctyp< !$list:var_list$.$t2$ >> in

but it doesn't work.

2) I tried building the polymorphic methods type declaration (e.g. 'a
'b. 'a->'b) by concatenation of strings
let method_type = (vars ^ " . " ^ function_type) in
let method_type_expanded = <:ctyp<$anti:method_type$>> in
     <:class_str_item< method $x$ : $method_type_expanded$ = $expression$ >>

compiles and works to some extent... it adds the antiquotation in the
translated .ml file which has two problems:
- it is an unparsed string, so no compiler checks on it
- it is surrounded by $ (e.g. method foo : $ 'a. 'a list -> 'a$ = ....)

Could you please explain how to have the antiquotation correctly parsed
by camlp4?
Am I on the wrong path? (I don't feel like writing a parser for type
expressions :( ).

Regards,
Massimiliano Brocchini (camlp4 beginner)


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

* Re: [Caml-list] Camlp4: ctyp antiquotation and polymorphic type question
  2007-07-26 12:46 ` Camlp4: ctyp antiquotation and polymorphic type question Massimiliano Brocchini
@ 2007-07-26 13:23   ` Nicolas Pouillard
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Pouillard @ 2007-07-26 13:23 UTC (permalink / raw)
  To: Massimiliano Brocchini; +Cc: caml-list

Excerpts from Massimiliano Brocchini's message of Thu Jul 26 14:46:24 +0200 2007:
> Hi,
> 
> I have a type expression stored in a string (obtained by cmigrep) and I
> need to attach it to a polymorphic method definition, but I can't obtain
> what I expected... I tried two solutions but I miserably failed:

The antiquotation $anti:...$ is not made to be used by the end-user. If you
have a type expression as a string, then you have to parse it. You can do that
by making an OCaml parser by appling some functors and then be able to parse
it and inject it correctly.

However for quantified variables, I suggest you to switch to a string list and don't try to treat them at once.

(* not tested, but made for camlp4orf *)
open Camlp4.PreCast;;
module Caml =
  Camlp4OCamlParser.Make
    (Camlp4OCamlRevisedParser.Make
      (Camlp4.OCamlInitSyntax.Make(Ast)(Gram)(Quotation)));;

let function_type = "'a -> 'b" in
let quant = ["'a"; "'b"] in
let parse_ctyp = Gram.parse_string Caml.ctyp (Loc.mk "<string>") in
let quant =
  List.fold_right
    (fun t acc -> <:ctyp< $parse_ctyp t$ $acc$ >>) quant <:ctyp<>> in
let function_type = parse_ctyp function_type in
<:class_str_item< method $x$ : ! $list:quant$ . $function_type$ = $expression$ >>

HTH

-- 
Nicolas Pouillard aka Ertai


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

end of thread, other threads:[~2007-07-26 13:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-25 15:38 Most recent CVS-branch? Markus Mottl
2007-07-25 17:52 ` Camlp4: ctyp antiquotation and polymorphic type question Massimiliano Brocchini
2007-07-26  8:28 ` [Caml-list] Most recent CVS-branch? Nicolas Pouillard
2007-07-26 12:46 ` Camlp4: ctyp antiquotation and polymorphic type question Massimiliano Brocchini
2007-07-26 13:23   ` [Caml-list] " 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).