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 (21:58)
From: Yaron Minsky <yminsky@c...>
Subject: Overriding an entry in a polymorphic variant
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.

Thanks in advance,