caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Veber <philippe.veber@gmail.com>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Unwanted type constraint in mutually recursive parameterized class type definition.
Date: Thu, 16 Jul 2015 18:00:40 +0200	[thread overview]
Message-ID: <CAOOOohSUbMx=dbjg8dJ1=E7LnYWr27anY9y7B7Ra7NXBvJQy2A@mail.gmail.com> (raw)
In-Reply-To: <10510894-97DB-4DA9-8334-F02C11E94504@math.nagoya-u.ac.jp>

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

This workaround worked just fine, thanks a lot!
ph.


2015-07-09 1:57 GMT+02:00 Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>:

> On 2015/07/09 01:24, Philippe Veber wrote:
> >
> > Dear camlers,
> >
> >   I obtain an unexpected answer from the toplevel when I enter the
> following definition:
> >
> >         OCaml version 4.03.0+dev7-2015-02-08
> >
> > # class type ['a] c =
> >   object
> >     method m : d
> >   end
> > and d =
> >   object
> >     inherit [int] c
> >   end
> > ;;
> > class type ['a] c = object constraint 'a = int method m : d end
> > and d = object method m : d end
> >
> > What surprises me is the constraint 'a = int in the definition of c. Is
> this is a bug or feature?
>
>
> This is a feature (or at least, the intended behavior)
> For classes, type constraints are inferred automatically, but in a
> monomorphic way.
> A standard workaround is to open the recursion by generalizing definitions:
>
> class type ['a,'d] c0 = object method m : 'd end
> class type d = object inherit ['a,d] c0 end
> class type ['a] c = ['a,d] c0
>
> Jacques Garrigue

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

      reply	other threads:[~2015-07-16 16:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 16:24 Philippe Veber
2015-07-08 23:57 ` Jacques Garrigue
2015-07-16 16:00   ` Philippe Veber [this message]

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='CAOOOohSUbMx=dbjg8dJ1=E7LnYWr27anY9y7B7Ra7NXBvJQy2A@mail.gmail.com' \
    --to=philippe.veber@gmail.com \
    --cc=caml-list@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).