English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Overriding an entry in a polymorphic variant
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-08-31 (22:05)
From: Yaron Minsky <yminsky@c...>
Subject: Re: Overriding an entry in a polymorphic variant
On 8/31/06, Yaron Minsky <yminsky@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, 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]