1 Sep 2006 01:29
Re: Re: Overriding an entry in a polymorphic variant
skaller <skaller <at> users.sourceforge.net>
2006-08-31 23:29:11 GMT
2006-08-31 23:29:11 GMT
On Thu, 2006-08-31 at 18:04 -0400, Yaron Minsky wrote: > On 8/31/06, Yaron Minsky <yminsky <at> cs.cornell.edu> wrote: > Does anyone know if there is a clean way of overriding a field > in a polymorhphic variant. I want to do something like this: > > type bot = [ `bot ] > type top = [`bot | `top] > type t = [ `a of bot | `b of bot | `c of bot | `d of bot | `e > of bot ] > type t1 = [ t | `c of top | `e of top ] > > the desired end result being that t1 is actually [ `a of bot | > `b of bot | `c of top | `d of bot | `e of top ]. I'm hoping > to do this largely to enable some phantom-types hackery I'm > working on. I'm not sure it matters from the point of view of > whether this is doable, but it is potentially relevant that > bot is a subtype of top. > > Small addendum: I'm still not sure this is relevant, It is .. > but I did get my example slightly backwards. top should be a subtype > of bot, not the other way. So the definitions of bot and top should > be: > > type bot = [ `bot | `top] > type top = [`top] Polymorphic variants are covariant in their arguments.(Continue reading)
RSS Feed