caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] What about polymorphic union types in functors?
@ 2004-02-06 15:51 Alex Baretta
  2004-02-06 17:43 ` brogoff
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Baretta @ 2004-02-06 15:51 UTC (permalink / raw)
  To: Ocaml

Here what I need to do:

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

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
end

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?

Alex

-------------------
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-02-09  1:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-06 15:51 [Caml-list] What about polymorphic union types in functors? Alex Baretta
2004-02-06 17:43 ` brogoff
2004-02-06 18:58   ` Alex Baretta
2004-02-09  1:40     ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).