caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: brogoff <brogoff@speakeasy.net>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Polymorphic method question
Date: Mon, 10 Jul 2006 22:22:42 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0607102157080.26509@shell2.speakeasy.net> (raw)
In-Reply-To: <20060711.110916.22502254.garrigue@math.nagoya-u.ac.jp>

On Tue, 11 Jul 2006, Jacques Garrigue wrote:

> From: brogoff <brogoff@speakeasy.net>
>
> Because bar is not yet completely defined when you use it in foobar.
> This is all related with parameter constraint inference: we don't know
> yet wether bar's parameter is really polymorphic or is constraint (e.g.
> 'a = 'b * 'c).
> Note that the problem does not occur with direct type definitions, as
> constraint inference is not done in that case (this is one of the
> reasons you cannot combine type and class definitions.)
>
> # type 'a bar = < get: 'a > and foobar = < f : 'a. 'a bar -> 'a >;;
> type 'a bar = < get : 'a >
> and foobar = < f : 'a. 'a bar -> 'a >
>
> The only way to solve this problem would be to remove parameter
> constraint inference from classes. It would certainly break some
> programs, so this seems difficult.

That's too bad, as it seems the class based OO version of the extensible
visitor is fairly straightforward in OCaml except for this counterintuitive
gotcha. What would have to be done to fix the broken programs? It may be
worth considering.

> By the way, if you're ready to define your types first, then you
> can do this properly.

In the more realistic example I sent along after, you'll see that this
solution is not really pleasing. You'd need to create a parallel type
hierarchy to match your class hierarchy, which is too verbose. All this
because we must have inference, which is supposed to make things less
verbose. Ironic, isn't it? ;-)

I have seen the new private rows stuff, which is very nice, but all of these
solutions IMO are way too complex to be considered satisfactory. I'll see if
the Java 1.5 approach actually works (I used some Pizza code to do the OCaml
implementation) because that was quite straightforward. I'd prefer approaches
that I can explain with a little hand waving. I think type theorists often
forget that there are a few programmers still who don't have PhDs in type
theory and will look at such solutions and conclude that OCaml is not for
them ;-).

-- Brian


  reply	other threads:[~2006-07-11  5:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-10 19:21 brogoff
2006-07-10 20:05 ` [Caml-list] " Richard Jones
2006-07-10 23:25   ` brogoff
2006-07-11  2:24     ` skaller
2006-07-11  4:56       ` brogoff
2006-07-11  2:09 ` Jacques Garrigue
2006-07-11  5:22   ` brogoff [this message]
2006-07-11  7:32     ` Jacques Garrigue
2006-07-11 18:20       ` brogoff
2006-07-12  0:37         ` Jacques Garrigue
2006-07-12 19:26           ` brogoff
  -- strict thread matches above, loose matches on Subject: below --
2002-08-21 21:49 [Caml-list] polymorphic " nadji
2002-08-21 22:57 ` Jacques Garrigue

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=Pine.LNX.4.58.0607102157080.26509@shell2.speakeasy.net \
    --to=brogoff@speakeasy.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).