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: Joel Reymont <joelr1@g...>
Subject: Re: Upgrading sexplib-2.7.0 to camlp4 3.10

On Apr 30, 2007, at 3:17 PM, Nicolas Pouillard wrote:

> id ::= lid | uid | id1 . id2 | id1 id2
>
> A function like tp_path is can be rewrite by a function that works
> only on idents.

So something like this then?

   let rec tp_path = function
     | <:ctyp< $lid:id$ >> | <:ctyp< $uid:id$ >> -> [id]
     | <:ctyp< $id:id$ >> ->
       (match id with
          | <:ident< $tp1$ . $tp2$ >> ->
            (match tp_path tp2 with [n] -> n | _ -> assert false) ::  
tp_path tp1
          | _ -> invalid_arg "tp_path")
     | _ -> invalid_arg "tp_path"

It does compile.


--
http://wagerlabs.com/