Browse thread
[Caml-list] What about polymorphic union types in functors?
- Alex Baretta
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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
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