From: Ivan Gotovchits <ivg@ieee.org>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] An inconsistency (possibly) in typing constraints with GADT
Date: Thu, 13 Jul 2017 21:00:57 -0400 [thread overview]
Message-ID: <CALdWJ+z+BKTAtmayiQVqOaF1V-g4GBkR=J8GE_GknvHiSwTSrA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]
Hi Everyone,
I'm wondering, is the following type definition rejected because there is
some fundamental reason, that I'm missing, or this is just a missed case in
the type checker?
type ('a,'b) domain = Domain
type 'd exp = Ret : 'a -> 'd exp constraint 'd = ('a,'b) domain
Fails with:
Error: Constraints are not satisfied in this type.
Type 'd exp should be an instance of ('a, 'b) domain exp
If we will express the same without GADT, it will be accepted, e.g.,
type 'd exp = Ret of 'a constraint 'd = ('a,'b) domain
And, of course, we can make typechecker happy with
type 'd exp = Ret : 'a -> ('a,'b) domain exp constraint 'd = ('a,'b)
domain
However, it will, somewhat, defeat the whole purpose of introducing the
constraint, as I'm using constraints as a sort of type abstraction to bind
type variables, and to my understanding the [constraint 'x =
<type-expression>] makes any occurrence of `'x` to be equivalent to the
<type-expression> in its scope.
Thanks,
Ivan
P.S. Of course, the provided example is a simplification of a real code,
where the constraint is really needed.
[-- Attachment #2: Type: text/html, Size: 4087 bytes --]
next reply other threads:[~2017-07-14 1:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 1:00 Ivan Gotovchits [this message]
2017-08-30 8:29 ` 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='CALdWJ+z+BKTAtmayiQVqOaF1V-g4GBkR=J8GE_GknvHiSwTSrA@mail.gmail.com' \
--to=ivg@ieee.org \
--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