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: camlp4 3.10: Matching variant types

On May 1, 2007, at 5:27 PM, Nicolas Pouillard wrote:

> << `id >> was encoded as RfTag(_loc, true, [])

So then  "RfTag (cnstr, _, [])", a constructor without arguments,  
would become <:ctyp< $`id$ >> whereas "RfTag (cnstr, _, tps)" <:ctyp<  
$id:tys$ >>?

Wasn't <:ctyp< $id$ >> used for something else already?

camlp4of -str '<:ctyp< int >>'
Ast.TyId (_loc, Ast.IdLid (_loc, "int"))

I thought that id is used for regular types, according to the above.

I tried to see what variant type defs expand to (below).

camlp4of -str '<:ctyp< [`Foo] >>'
Ast.TyVrnEq (_loc, Ast.TyVrn (_loc, "Foo"))

camlp4of -str '<:ctyp< [Foo] >>'
Ast.TyVrnEq (_loc, Ast.TyId (_loc, Ast.IdUid (_loc, "Foo")))

camlp4of -str '<:ctyp< [`Foo|`Bar] >>'
Ast.TyVrnEq (_loc,
   Ast.TyOr (_loc, Ast.TyVrn (_loc, "Foo"), Ast.TyVrn (_loc, "Bar")))

camlp4of -str '<:ctyp< [Foo|Bar] >>'
Ast.TyVrnEq (_loc,
   Ast.TyOr (_loc, Ast.TyId (_loc, Ast.IdUid (_loc, "Foo")),
     Ast.TyId (_loc, Ast.IdUid (_loc, "Bar"))))

Is there a "ctyp", "id", "lid", etc. shortcut that should be used for  
TyVrnEq? Is there a path through the camlp4 sources that would enable  
me to figure this out?

Ast.TyId (_loc, Ast.IdUid (_loc, "Foo")

This is matched by $id:uid", correct?

Is there a "shortcut" for TyOr and TyVrn?

I'm afraid I'm still lost here, thus my asking for more information.

	Thanks, Joel

--
http://wagerlabs.com/