caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nicolas Trangez <nicolas@incubaid.com>
To: Caml-list <caml-list@inria.fr>
Subject: [Caml-list] Strange interaction between recursive modules, GADT exhaustiveness checking and type-checking?
Date: Sun, 29 Jun 2014 00:55:32 +0200	[thread overview]
Message-ID: <1403996132.26873.18.camel@chi.nicolast.be> (raw)

All,

I was working on some code lately (admittedly, pushing some boundaries
w.r.t. recursive modules & GADTs), and got some confusing results.

All of this using OCaml 4.01.0, using `-w +A -warn-error +A`.

I tried to break it down to a small test-case, which you can find at
https://gist.github.com/NicolasT/3a6ef50d5607b744206b

The first case, implemented in module `W`, works as expected. No
warnings about a pattern match for `W (BB, _)` missing in `W.f`. Jay!

When doing something fairly similar in a couple of recursive modules
below, things become confusing. The compiler warns about a missing case
for `W (T.BB, _)` in `S.f`, as noted above it, whilst I think that
pattern shouldn't even type-check... I validated this by adding some
code at the end (in the `demo` function), trying to call `S.f` with a
`B.b S.w` argument, and this fails (as expected & desired). So why would
I be forced, or even allowed, to match on this case in `S.f` at all?

Nicolas


             reply	other threads:[~2014-06-28 22:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-28 22:55 Nicolas Trangez [this message]
2014-06-29 14:49 ` Grégoire Henry
2014-06-30 11:07   ` Ben Millwood

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=1403996132.26873.18.camel@chi.nicolast.be \
    --to=nicolas@incubaid.com \
    --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;
as well as URLs for NNTP newsgroup(s).