Version française
Home     About     Download     Resources     Contact us    
Browse thread
Camlp4 3.10.0+beta: lists without $list:...$
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin.jambon@e...>
Subject: Camlp4 3.10.0+beta: lists without $list:...$
I managed to create an object type using camlp4orf:

let ctyp_object _loc ml =
   let fields =
     List.fold_left
       (fun o (name, typ) ->
 	 let m = <:ctyp< $lid:name$ : $typ$ >> in
 	 <:ctyp< $o$; $m$ >>)
       <:ctyp< >> ml in
   <:ctyp< < $fields$ > >>

where ml is a list of method declarations of type (string * ctyp) list.
Before we just had to do this:

<:ctyp< < $list:ml$ > >>


Is there anything simpler than my solution? Is a shortcut available?


If not, I think there should really be one. By the way, there should also 
be some shortcut for building list patterns and expressions without 
List.fold_*. A library could do that.


Martin


PS: any progress on the manual? It's kind of hard to test new features 
when you don't know what they are.

--
Martin Jambon
http://martin.jambon.free.fr