caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Veber <philippe.veber@googlemail.com>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Typing of polymorphic variants
Date: Thu, 16 Apr 2009 14:31:45 +0200	[thread overview]
Message-ID: <721f7f5a0904160531h5b31fd0djac95fe0d534737fe@mail.gmail.com> (raw)
In-Reply-To: <20090416.212314.107686494.garrigue@math.nagoya-u.ac.jp>

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

2009/4/16 Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>

> From: Philippe Veber <philippe.veber@googlemail.com>
> > I don't understand the following behaviour:
> >
> >         Objective Caml version 3.11.0
> >
> > # type t = [`A | `B of int u] and 'a u = 'a * t;;
> > Error: In the definition of t, type int u should be 'a u
> > # type t = A | B of int u and 'a u = 'a * t;;
> > type t = A | B of int u
> > and 'a u = 'a * t
> >
> > Anyone's got a simple explanation for this ?
>
> This is due to the difference between type abbreviations and
> datatypes. In your first example, you are defining two types
> abbreviations, and you are not allowed to instantiate a type you are
> defining in mutual recursion. In the second example, you are defining a
> datatype and a type abbreviation, and it is ok to instantiate the type
> abbreviation inside the datatype definition.
>
> The technical reason for this difference is the restriction to regular
> types in type abbreviations. It only applies when the definitions are
> mutually recursive, and do not go through any datatype definition.


Indeed, I noticed in other attempts that some definitions that would be
accepted in the form type t = ... type u = ... were rejected in the form
type t = ... and u = ... Now with your explanation it's clear why. Many
thanks !

ph.


>
>
> Jacques Garrigue
>

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

  reply	other threads:[~2009-04-16 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-15 12:48 Philippe Veber
2009-04-16 12:23 ` [Caml-list] " Jacques Garrigue
2009-04-16 12:31   ` Philippe Veber [this message]
2009-04-16 12:44     ` Philippe Veber

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=721f7f5a0904160531h5b31fd0djac95fe0d534737fe@mail.gmail.com \
    --to=philippe.veber@googlemail.com \
    --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).