From: Jeremy Yallop <yallop@gmail.com>
To: Christopher Zimmermann <christopher@gmerlin.de>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] matching GADT option types
Date: Thu, 17 Jan 2019 09:58:46 +0000 [thread overview]
Message-ID: <CAAxsn=F+ZLH3z=a02_KP4kyYz_DKqu7C_1kY0vz9X8pynNHEtQ@mail.gmail.com> (raw)
In-Reply-To: <20190117104611.3288dd5a@mortimer.gmerlin.de>
On Thu, 17 Jan 2019 at 09:46, Christopher Zimmermann
<christopher@gmerlin.de> wrote:
> why does the f type correctly while g fails to type?
>
> Christopher
>
> type 'a t =
> | A : unit t
>
> let f =
> fun (type a) ~(p :a t option) () -> match p with
> | Some A -> ()
> | None -> ()
>
> let g =
> fun (type a) ~(p :a t option) () -> match p with
> | Some A (* TYPING ERROR HERE *)
> | None -> ()
>
> Error: This pattern matches values of type unit t
> but a pattern was expected which matches values of type a t
> Type unit is not compatible with type a
GADT matching under or-patterns isn't currently supported in the
current release. However, the following PR added some support, and
your code is now accepted with the trunk compiler:
Allow GADT constructors to introduce equations and existential
types under or-patterns
https://github.com/ocaml/ocaml/pull/2110
next prev parent reply other threads:[~2019-01-17 9:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 9:46 Christopher Zimmermann
2019-01-17 9:58 ` Jeremy Yallop [this message]
2019-01-17 10:02 ` Christopher Zimmermann
2019-01-17 10:18 ` Gabriel Scherer
2019-01-17 10:12 ` Gabriel Scherer
2019-01-17 10:08 ` Christopher Zimmermann
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='CAAxsn=F+ZLH3z=a02_KP4kyYz_DKqu7C_1kY0vz9X8pynNHEtQ@mail.gmail.com' \
--to=yallop@gmail.com \
--cc=caml-list@inria.fr \
--cc=christopher@gmerlin.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