caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dario Teixeira <darioteixeira@yahoo.com>
To: caml-list@yquem.inria.fr
Subject: Merging object signatures
Date: Thu, 4 Nov 2010 11:55:47 -0700 (PDT)	[thread overview]
Message-ID: <313968.60910.qm@web111509.mail.gq1.yahoo.com> (raw)

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






             reply	other threads:[~2010-11-04 18:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04 18:55 Dario Teixeira [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=313968.60910.qm@web111509.mail.gq1.yahoo.com \
    --to=darioteixeira@yahoo.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).