From: Goswin von Brederlow <goswin-v-b@web.de>
To: Dario Teixeira <darioteixeira@yahoo.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Merging object signatures
Date: Thu, 04 Nov 2010 21:01:49 +0100 [thread overview]
Message-ID: <87k4ksdfiq.fsf@frosties.localdomain> (raw)
In-Reply-To: <313968.60910.qm@web111509.mail.gq1.yahoo.com> (Dario Teixeira's message of "Thu, 4 Nov 2010 11:55:47 -0700 (PDT)")
Dario Teixeira <darioteixeira@yahoo.com> writes:
> 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
Can't you make foo_t and bar_t class types and foobar_t inherits them
both?
MfG
Goswin
next prev parent reply other threads:[~2010-11-04 20:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-04 18:55 Dario Teixeira
2010-11-04 20:01 ` Goswin von Brederlow [this message]
2010-11-05 12:58 ` [Caml-list] " 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=87k4ksdfiq.fsf@frosties.localdomain \
--to=goswin-v-b@web.de \
--cc=caml-list@yquem.inria.fr \
--cc=darioteixeira@yahoo.com \
/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