caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Camlp4 question on type declarations
@ 2007-06-14  5:38 Christian Stork
  2007-06-23 16:09 ` [Caml-list] " Nicolas Pouillard
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Stork @ 2007-06-14  5:38 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Camlp4 question on type declarations
  2007-06-14  5:38 Camlp4 question on type declarations Christian Stork
@ 2007-06-23 16:09 ` Nicolas Pouillard
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Pouillard @ 2007-06-23 16:09 UTC (permalink / raw)
  To: caml-list

On 6/14/07, Christian Stork <caml-list@cstork.org> wrote:
> I'd like to construct a quotation that acts as the following pattern.
>
>     Ast.StTyp (_, (Ast.TyDcl (_, name, params, t, _)))

The TyDcl node is the only node that does not have a syntax equivalence.

Of course you can have a complete type declaration in a quotation but
holes cannot be used everywhere, so you have to use the node directly.

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-23 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-14  5:38 Camlp4 question on type declarations Christian Stork
2007-06-23 16:09 ` [Caml-list] " Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).