caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: serp@stork.ru
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Recursive parametrized classes bug?
Date: Thu, 18 Sep 2008 19:12:23 +0900 (JST)	[thread overview]
Message-ID: <20080918.191223.45889871.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <1221726687.15768.3.camel@serphost.localdomain>

From: Сергей Плаксин <serp@stork.ru>

> >>> cat test.ml
> class type ['a] a  =
>   object
>     method v: 'a
>   end
> and b =
>   object
>     inherit [int] a
>   end
> and c =
>   object
>     inherit [float] a
>   end
> =======
> File "test.ml", line 15, characters 13-18:
> The type parameter float does not meet its constraint: it should be int

The reason is simple enough: for classes and class types, the
parameter are only generalized once the definition is finished.
As a result, using a parameterized class type inside a recursive
definition introduces constraints on parameters.

The classical workaround is to break the recursion (when needed) by
adding more parameters. Another trick is to use recursive modules, but
this is actually more verbose, and rather fragile as constraints on
recursive modules can be subtle.

Jacques Garrigue

      reply	other threads:[~2008-09-18 10:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-18  8:31 Сергей Плаксин
2008-09-18 10:12 ` Jacques Garrigue [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=20080918.191223.45889871.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=serp@stork.ru \
    /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).