caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Christoph Höger" <christoph.hoeger@tu-berlin.de>
To: caml users <caml-list@inria.fr>
Subject: [Caml-list] Infer least upper bound for arguments to functions in rows
Date: Wed, 30 Mar 2016 12:28:07 +0200	[thread overview]
Message-ID: <56FBAA37.5080403@tu-berlin.de> (raw)

Dear experts,

is there a way to infer a compatible type for the argument to t#x in the
function:

let a t = ignore (t#x t) ; t#x (object end) ;;

I can easily provide a compatible t, e.g.:

let t = object method x _ = 23 end

I can also use a coercion:

let a t = ignore (t#x (t :> < >)) ; t#x (object end) ;;

Since < > is the common supertype of both arguments.

My problem is that in general < > won't suffice for the common type, and
finding it is a rather complicated process. So I wonder if there is some
clever rewriting of the function that makes ocamlc infer that type for me?

Is there any expression that for two (expressions with) different input
types yields (an expression of) the largest common supertype?

regards,

Christoph
-- 
Christoph Höger

Technische Universität Berlin
Fakultät IV - Elektrotechnik und Informatik
Übersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin

Tel.: +49 (30) 314-24890
E-Mail: christoph.hoeger@tu-berlin.de

             reply	other threads:[~2016-03-30 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 10:28 Christoph Höger [this message]
2016-03-31 10:41 ` Goswin von Brederlow

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=56FBAA37.5080403@tu-berlin.de \
    --to=christoph.hoeger@tu-berlin.de \
    --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).