From: David RENAULT <renault@labri.fr>
To: caml-list@inria.fr
Subject: [Caml-list] GADTs : a type variable cannot be deduced
Date: Fri, 25 Oct 2013 14:08:10 +0200 [thread overview]
Message-ID: <526A5F2A.6060904@labri.fr> (raw)
Hi,
I was experimenting on GADTs and phantom types and was using the usual
encoding for naturals, as well as a classic implementation of the
associated singleton type :
type zero
type 'a succ
type _ nat =
| Zero : zero nat
| Succ : 'a nat -> ('a succ) nat
With ocamlc 4.01.0, this fails to compile with the following error
message :
Error: In this definition, a type variable cannot be deduced
from the type parameters.
This is strange, because this code compiled pretty well with ocamlc
4.00.1. Of course, it is possible to modify the code to make it compile
by replacing the type variables by underscores, but the resulting type
is incorrect :
type _ nat =
| Zero : zero nat
| Succ : _ nat -> (_ succ) nat
(* type _ nat = Zero : zero nat | Succ : 'b nat -> 'a succ nat *)
Succ Zero;; (* 'a succ nat = Succ Zero, should be "zero succ nat" *)
I failed to find in the Changelog the modification that led to this
behavior, and nothing really simple about the error message showed up.
The following file seems to prove that the problem appears in various
other cases :
http://caml.inria.fr/svn/ocaml/trunk/testsuite/tests/typing-gadts/pr5985.ml
Is the code I am writing incorrect ? (for reference, the same code in
Haskell (with ghc) works as expected)
RENAULT David
next reply other threads:[~2013-10-25 12:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-25 12:08 David RENAULT [this message]
2013-10-25 12:25 ` Gabriel Scherer
2013-10-29 14:17 ` David RENAULT
2013-10-29 14:47 ` Gabriel Scherer
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=526A5F2A.6060904@labri.fr \
--to=renault@labri.fr \
--cc=caml-list@inria.fr \
/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