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
[Caml-list] What about polymorphic union types in functors?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-02-06 (15:51)
From: Alex Baretta <alex@b...>
Subject: [Caml-list] What about polymorphic union types in functors?
Here what I need to do:

module type FRAGMENT = sig
   type foo (* Closed polymorphic union type *)
   val do_something : foo -> whatever

module Merge_fragments (F1:FRAGMENT) (F2:FRAGMENT) : #FRAGMENT = struct
   type foo = [ F1.foo | F2.foo ]
   let do_something = function
     | #F1.foo as f1 -> F1.do_something f1
     | #F2.foo as f2 -> F2.do_something f2

Up to now I have used automatic code generation to actually write the ML 
file which implements the functor istantiation. Could such an extension 
be made to Ocaml type system?


To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners