Version française
Home     About     Download     Resources     Contact us    
Browse thread
defining recursive types with camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: blue storm <bluestorm.dylc@g...>
Subject: Re: [Caml-list] defining recursive types with camlp4
On Sun, Jun 14, 2009 at 11:10 PM, Jacques Le
Normand<rathereasy@gmail.com> wrote:
> how would I go about writing such a function?

The "... and ..." multiple-declaration isn't at the str_item level but
at the ctyp level. You should use <:ctyp< $..$ and $...$ >>. Moreover,
it appears that the type declaration node in the AST (Ast.TyDcl) does
not have a quotation syntax : <:str_item< type $..$ = $...$ >> won't
work.

  let type_chain _loc  lst =
    let decl (name, constructors) = Ast.TyDcl(_loc, name, [],
constructors, []) in
    <:str_item< type $Ast.tyAnd_of_list (List.map decl lst)$ >>