Version française
Home     About     Download     Resources     Contact us    
Browse thread
Upgrading sexplib-2.7.0 to camlp4 3.10
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: Upgrading sexplib-2.7.0 to camlp4 3.10
On 5/1/07, Joel Reymont <joelr1@gmail.com> wrote:
> Moving on! I hope this long thread will be instructive for later
> Google searches.
>
>    (* Get the path associated with a polymorphic type *)
>    let rec get_appl_path _loc = function
>      | <:ctyp< $lid:_$ >> as tp -> tp
>      | <:ctyp< $_$ . $_$ >> as tp -> tp
>      | <:ctyp< $tp$ $_$ >> -> get_appl_path _loc tp
>      | _ -> failwith "get_appl_path: unknown type"
>
> File "pa_sexp_conv.ml", line 320, characters 22-25:
> While expanding quotation "ctyp" in a position of "patt":
>    Parse error: ident_of_ctyp: this type is not an identifier
>
> That would be <:ctyp< $_$ . $_$ >> as tp -> tp
>
> It would work (from what I understand) if it was <:ctyp< ! $_$ . $_$
>  >> but what does this match and how to fix it?
>
>         Thanks, Joel
>

No there is a difference between <:ctyp< ! 'a ... 'z . typ >> and
<:ctyp< id1.id2 >> the first one means forall, the second one is the
access of the `id2' field of the module `id1'.

The goal the function get_appl_path is to get the type constructor, so
go down left into all type applications.

Reminder, type application depends on the syntax:

original syntax: int list, (string, int list) Hashtbl.t
revised syntax: list int, Hashtbl.t string (list int)

If I well remember, you use camlp4of, so that's the original syntax.

Then you should go right in application nodes: <:ctyp< $_$ $t$ >>.

    let rec get_appl_path _loc = function
      | <:ctyp< $id:i$ >> -> i
      | <:ctyp< $_$ $tp$ >> -> get_appl_path _loc tp
      | _ -> failwith "get_appl_path: unknown type"

-- 
Nicolas Pouillard