Version française
Home     About     Download     Resources     Contact us    
Browse thread
Camlp4 question on type declarations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian Stork <caml-list@c...>
Subject: Camlp4 question on type declarations
I'd like to construct a quotation that acts as the following pattern.

    Ast.StTyp (_, (Ast.TyDcl (_, name, params, t, _)))

How can I do this?  The obvious attempt 

    <:str_item< type $lid:name$ $list:params$ = $t$ >>

doesn't work because the 'list' antiquotation expander is not supported
(and AFAIU would be against the "spirit" of the overhault camlp4, altho
I wouldn't know why in this case).

There seem to be two problems.  First, if one writes 

    <:str_item< type $lid:name$ $params$ = $t$ >>

(without the 'list:') then this pattern only matches a single parameter.

    <:str_item< type $name_and_params$ = $t$ >>

doesn't work, even though one could think of name_and_params as a single
ctyp where name is applied to the params. (Wouldn't that be more
consistet with the modeling of type application in the rest of camlp4?)

Second problem: the above patterns only match type declarations without
any constraints.  Something like

    <:str_item< type $lid:name$ $param$ = $t$ $_$ >>

doesn't work either.  (Admittedly, that would be hard to decypher
anyway.)  The following only matches exactly one constraint.

    <:str_item< type $lid:name$ $param$ = $t$ constraint $_$ = $_$ >>

Any solutions or do I have to fall back on using the underlying AST
constructors?

-- 
Chris Stork   <>  Support eff.org!  <>   http://www.ics.uci.edu/~cstork/
OpenPGP fingerprint:  B08B 602C C806 C492 D069  021E 41F3 8C8D 50F9 CA2F