caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leo White <leo@lpw25.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] extend object type?
Date: Fri, 10 Feb 2017 04:42:39 -0500	[thread overview]
Message-ID: <1486719759.2807473.876601792.517B151E@webmail.messagingengine.com> (raw)
In-Reply-To: <CAGh2ivA_QJSutzQDrRM7tamZh=Q4hpZHVxraVwtt7fx9jufuLQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

You can't do it for object types directly, but you can do it for
class types:


  class type t1 = object method f : int end



  class type t2 = object inherit t1 method g : bool end



Defining a class type also defines the corresponding object type, which
means the above results in types called t1 and t2 that are equal to the
ones you want.


This trick also lets you use #t2 to refer to the polymorphic type < f :
int; g : bool; .. >.


Regards,



Leo



On Thu, 9 Feb 2017, at 11:15 PM, Steffen Smolka wrote:

> Is there syntax to conveniently extend object types?

> Concretely, for types

> 

> type t1 = < f : int >

> type t2 = < f : int; g : bool >

> 

> I would like a syntax that allows me to define t2 in terms of t1.

> 

> Thanks!

> -- Steffen



[-- Attachment #2: Type: text/html, Size: 1273 bytes --]

  parent reply	other threads:[~2017-02-10  9:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-10  4:15 Steffen Smolka
2017-02-10  8:30 ` Kakadu
2017-02-10  9:42 ` Leo White [this message]
2017-02-10 14:49 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2017-02-10 16:43 Steffen Smolka

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=1486719759.2807473.876601792.517B151E@webmail.messagingengine.com \
    --to=leo@lpw25.net \
    --cc=caml-list@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).