From: David RENAULT <renault@labri.fr>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] GADTs : a type variable cannot be deduced
Date: Tue, 29 Oct 2013 15:17:29 +0100 [thread overview]
Message-ID: <526FC379.30506@labri.fr> (raw)
In-Reply-To: <CAPFanBEW=uEY2ZFTGG8ZmHsZpLZdi-Hfc=FpMABHC12Y_00UWA@mail.gmail.com>
Gabriel Scherer wrote:
> The problem is with the assumed injectivity of the abstract type 'a
> succ. You should write:
>
> type 'a succ = Succ
>
> then everything works out.
>
> Injectivity was assumed to hold for types *defined* to be abstract, but
> does not hold for types *declared* as abstract (That may have been
> defined concretely as just "int" in their implementation). For
> consistency, defined-abstract type are no more assumed to be injective,
> so you should always use a constructor for that (using a constructor
> makes your type nominal/generative/fresh, which enforces injectivity).
>
> Remark: I'll let you work out while it would be problematic to consider
> a ('a succ succ nat)-matching branch as dead when matching over a ('a
> succ nat) value, under the definition (type 'a succ = int).
OK, thank you for your answer, I have taken some time to dive into the
question of injectivity of types, and I believe that there is something
I am missing. With your help, the following code compiles :
====================================================================
type 'a succ = Succ
type _ nat = NS : 'a nat -> ('a succ) nat
====================================================================
If we leave the type abstract, then the type function NS may not be
injective. But if we give a concrete implementation with a constructor,
it works out. To me, the concrete implementation is not injective (it
maps everything on "Succ nat"), but you proclaim that it becomes
automatically injective. Why does mapping everything onto a new type
enforce injectivity ?
RENAULT David
next prev parent reply other threads:[~2013-10-29 14:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-25 12:08 David RENAULT
2013-10-25 12:25 ` Gabriel Scherer
2013-10-29 14:17 ` David RENAULT [this message]
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=526FC379.30506@labri.fr \
--to=renault@labri.fr \
--cc=caml-list@inria.fr \
--cc=gabriel.scherer@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