Version française
Home     About     Download     Resources     Contact us    
Browse thread
Transforming of ASTs and polymorphic variants
[ 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: Transforming of ASTs and polymorphic variants
My apologies if this is a beginners question...

I have two ASTs in different modules that look very much alike in  
that some constructors have the same name and type name. When I  
transform that ASTs I end up "re-applying" the similarly named  
constructor and arguments. This is best explained with an example.

a.ml:

type typ =
   | Integer
   | Double
   | String
   | Boolean

b.ml:

type ty =
   | Integer
   | Double
   | String
   | Boolean
   | Void

A transformation function would be

let conv_type = function
   | A.Integer -> B.Integer
   | A.String -> B.String
   | A.Boolean -> B.Boolean

I don't want to share types between ASTs since, like above, some of  
them may be supersets of others. How can I improve this with  
polymorphic variants?

	Thanks, Joel

--
http://wagerlabs.com/