caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Goswin von Brederlow <goswin-v-b@web.de>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Error: In this definition, a type variable cannot be deduced from the type parameters
Date: Sun, 23 Feb 2014 18:18:19 +0900	[thread overview]
Message-ID: <CFE29202-976B-4A65-AA5A-597CF7649A8C@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <20140222175435.GA21007@frosties>

On 2014/02/23 02:54, Goswin von Brederlow wrote:

> Hi,
> 
> I'm stuck trying to solve this error:
> 
>    Error: In this definition, a type variable cannot be deduced
>           from the type parameters.
> 
> The error happens when I use the "type 'a node = InnerNode.t" from the
> comment and disapears when I box it in a constructor as shown below.
> 
> Can anyone explain what is missing that makes the extra constructor
> necessary?
> 
> MfG
> 	Goswin
> 
> PS: needs and must work with ocaml 4.01.

Actually it seems that you have already found the solution:
if a type variable appears in the return type of a gadt, and is used
in the body, injectivity under invariance must be guaranteed for this return type.
This is the famous PR#5985.
Injectivity is broken if the type variable can disappear by expanding
any abbreviation in the type, such as node in your case.
By making node a nominal type, you prevented that.
Note that using a private abbreviation would not be sufficient here,
as a private abbreviation can be used to hide a normal abbreviation.

If you dislike the change in internal representation for node,
you can also define a separate type for the gadt parameter.
Except in very specific cases, there is no strong reason for the
gadt parameter type and the concrete type to coincide.

	Jacques

  reply	other threads:[~2014-02-23  9:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-22 17:54 Goswin von Brederlow
2014-02-23  9:18 ` Jacques Garrigue [this message]
2016-03-06  1:33 Goswin von Brederlow
2016-03-06 15:30 ` 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=CFE29202-976B-4A65-AA5A-597CF7649A8C@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=goswin-v-b@web.de \
    /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).