Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: thelema314@gmail.com
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Error: In the definition of t, type ('a, 'b) t should be ('b, 'a) t
Date: Wed, 06 Jan 2010 16:47:36 +0900 (JST)	[thread overview]
Message-ID: <20100106.164736.44969841.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <4B443038.5020204@gmail.com>

From: Edgar Friendly <thelema314@gmail.com>
> This error message was new to me, and I wondered what's going on and
> why:
> 
> # type ('a, 'b) t = [ `A | `T of ('b, 'a) t ];;
> Error: In the definition of t, type ('a, 'b) t should be ('b, 'a) t

Structural recursive types (objects and polymorphic variants) must be
regular. I.e., type abbreviations must always have the same
parameters.
The error message is a bit confusing, due to the way type variables
are printed  (original names are not kept), but it says that type
parameters got exchanged.

If you really want to define this type, you have to unroll it by hand:

type ('a, 'b) t = [ `A of 'a | `T of [ `A of 'b | `T of ('a,'b) t]];;

(I added an argument to `A to make the parameters meaningful.)

Jacques Garrigue




      reply	other threads:[~2010-01-06  7:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06  6:39 Edgar Friendly
2010-01-06  7:47 ` 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=20100106.164736.44969841.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@yquem.inria.fr \
    --cc=thelema314@gmail.com \
    /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