caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Merging object signatures
@ 2010-11-04 18:55 Dario Teixeira
  2010-11-04 20:01 ` [Caml-list] " Goswin von Brederlow
  0 siblings, 1 reply; 5+ messages in thread
From: Dario Teixeira @ 2010-11-04 18:55 UTC (permalink / raw)
  To: caml-list

Hi,

Similarly to polymorphic variants, is there a way for object signatures to
be merged by type name?  Consider the example at the end; I'm wondering if
it is possible for the declaration of 'foobar' to be something along the
lines of 'val foobar: int -> int -> < foo_t; bar_t >' instead of needing to
explicitly list all the methods in foo_t and bar_t.

Thanks in advance for your help!
Best regards,
Dario Teixeira


module Test:
sig
	type foo_t = < a: int >
	type bar_t = < b: int >

	val foobar: int -> int -> < a:int; b: int >

	(* val foobar: int -> int -> < foo_t; bar_t > *)
end =
struct
	type foo_t = < a: int >
	type bar_t = < b: int >

	class foo a = object method a: int = a end
	class bar b = object method b: int = b end

	let foobar a b =
	object
		inherit foo a
		inherit bar b
	end
end






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

end of thread, other threads:[~2010-11-05 17:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-04 18:55 Merging object signatures Dario Teixeira
2010-11-04 20:01 ` [Caml-list] " Goswin von Brederlow
2010-11-05 12:58   ` Dario Teixeira
2010-11-05 14:45     ` Jacques Garrigue
2010-11-05 17:58       ` Dario Teixeira

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