From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 1A8E97FCCF for ; Wed, 14 Oct 2015 04:13:52 +0200 (CEST) IronPort-PHdr: 9a23:+n/ARB26VI/5GopbsmDT+DRfVm0co7zxezQtwd8ZsegeLfad9pjvdHbS+e9qxAeQG96Lt7QU1aGL7ujJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd6OyZTpnL3vs7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cYk7sb+sVBSaT3ebgjBfwdVWx+cjN92Mq+lxTZQA6erkoVVmERilIcEgHB6Bbidpj0uyr+8OF63X/JE9fxSOUdUzir66NiSFfTgSkJNjI49myf3sV6gKtfpBuh4Qd2zYDVbICTOdJxe6rceZURQm8XDZUZbDBIHo7pN9hHNOEGJ+sN6tCl/1Y= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=abdallah.saffidine@gmail.com; spf=Pass smtp.mailfrom=abdallah.saffidine@gmail.com; spf=None smtp.helo=postmaster@mail-wi0-f178.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of abdallah.saffidine@gmail.com) identity=pra; client-ip=209.85.212.178; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="abdallah.saffidine@gmail.com"; x-sender="abdallah.saffidine@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of abdallah.saffidine@gmail.com designates 209.85.212.178 as permitted sender) identity=mailfrom; client-ip=209.85.212.178; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="abdallah.saffidine@gmail.com"; x-sender="abdallah.saffidine@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f178.google.com) identity=helo; client-ip=209.85.212.178; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="abdallah.saffidine@gmail.com"; x-sender="postmaster@mail-wi0-f178.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DtAQAEuh1WlLLUVdFeg3puBr9zI4Jwggp/AoE7BzsRAQEBAQEBAQEQAQEBAQcLCwkfMIIfggcBAQECAQESEQQZARsdAQMBCwYFBAcNKgICIQEBEQEFARwGEwgBGYd2AQMKCA2hJ4ExPjGLSYFsgnmJAwoZJw1WhDQBAQEBAQUBAQEBAQEWAQUOhmeEfoJQgj0HgmmBRQWNDoVIg0CLJoF0gViSZ4NagiMSI4EXN4IwIx2BUiozAYZwAQEB X-IPAS-Result: A0DtAQAEuh1WlLLUVdFeg3puBr9zI4Jwggp/AoE7BzsRAQEBAQEBAQEQAQEBAQcLCwkfMIIfggcBAQECAQESEQQZARsdAQMBCwYFBAcNKgICIQEBEQEFARwGEwgBGYd2AQMKCA2hJ4ExPjGLSYFsgnmJAwoZJw1WhDQBAQEBAQUBAQEBAQEWAQUOhmeEfoJQgj0HgmmBRQWNDoVIg0CLJoF0gViSZ4NagiMSI4EXN4IwIx2BUiozAYZwAQEB X-IronPort-AV: E=Sophos;i="5.17,681,1437429600"; d="scan'208";a="150461076" Received: from mail-wi0-f178.google.com ([209.85.212.178]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 14 Oct 2015 04:13:47 +0200 Received: by wicgb1 with SMTP id gb1so111307588wic.1 for ; Tue, 13 Oct 2015 19:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=OnHuEQHCT3LIxxigOqhllDNODkm8lIyv8rnQUf68jIM=; b=xaphtZNtRyj4f6sYEELGXLgfObb03Lmc75engaSK1UyS5M5E10GYuQ1XqhTCfxBrLW p5gp2DWiDDcy5p80mUHzjGlNHIdQbMg4lfFov9jLEfkI8tw301wFeY70rz0iwIuTVl2v UTRJfInBIhRYhQV/D5LlDtjJhMry3h1bQSUQPSuSKVF2Ptpx0cnXOIjIhDUS3LKh19U7 tw1HinPB+9nAsBl64gydCSzeZjl73N8Z/epwCbbYFhsBG3HxIYG2rEtElskg682yEJc1 60onDHPUHFj588a3+TAUjMXm1yzqpcss8VwWxvaB/9G3CoGJLhx3BDKGjRGag5NVb4pi 7ANg== X-Received: by 10.194.87.74 with SMTP id v10mr632699wjz.114.1444788827420; Tue, 13 Oct 2015 19:13:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.27.108.71 with HTTP; Tue, 13 Oct 2015 19:13:27 -0700 (PDT) In-Reply-To: References: From: Abdallah Saffidine Date: Wed, 14 Oct 2015 13:13:27 +1100 Message-ID: To: Jeremy Yallop Cc: Ben Millwood , Philippe Veber , caml users Content-Type: multipart/alternative; boundary=047d7bf109dcd57d7a0522071cf3 X-Validation-by: abdallah.saffidine@gmail.com Subject: Re: [Caml-list] How to use GADTs across modules in OCaml without raising warnings? --047d7bf109dcd57d7a0522071cf3 Content-Type: text/plain; charset=UTF-8 Dear all, Thanks a lot for your help. Things are much clearer now. Abdallah 2015-10-13 20:45 GMT+11:00 Jeremy Yallop : > On 13 October 2015 at 07:15, Ben Millwood > wrote: > > I'll advance on others' advice by pointing out that if you say: > > > > type never = private [`never] > > > > then you neither "use up" a constructor name nor is it possible to write > an > > expression with type never. > > A nit: there are lots of *expressions* of type 'never', such as > '(assert false: never)'. However, there are no (closed) *values* of > type 'never'. > > > Unfortunately, the compiler still doesn't realise that, so it > > doesn't help you for pattern-matching. > > The gadt-warnings branch, which is described here: > > GADTs and exhaustiveness: looking for the impossible > Jacques Garrigue's and Jacques Le Normand > ACM SIGPLAN Workshop on ML, September 2015 > > http://www.mlworkshop.org/gadts-and-exhaustiveness-looking-for-the-impossible.pdf > > includes better supports for "empty" types. For example, here's a > definition of an empty type 'wrong': > > type 'a is_true = T: [`True] is_true > type wrong = [`False] is_true > > and here's a function definition which omits a case that you can > deduce is unmatchable when you know that 'wrong' is empty: > > let f : wrong option -> unit = fun None -> () > > The current OCaml compiler (4.02.3) issues a warning for 'f': > > Warning 8: this pattern-matching is not exhaustive. > Here is an example of a value that is not matched: > Some _ > > In contrast, the compiler in the gadt-warnings branch compiles 'f' > without complaint (and generates more efficient code, since there's no > need to inspect the argument). > > Jeremy. > --047d7bf109dcd57d7a0522071cf3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Dear all,

Thanks a lot for your hel= p. Things are much clearer now.

Abdallah

2015-10-13 20:45 GMT+11:00 = Jeremy Yallop <yallop@gmail.com>:
On 13 October 2015 at 07:15, Ben Millwood <bmillwood@janestreet.com> wro= te:
> I'll advance on others' advice by pointing out that if you say= :
>
> type never =3D private [`never]
>
> then you neither "use up" a constructor name nor is it possi= ble to write an
> expression with type never.

A nit: there are lots of *expressions* of type 'never', such= as
'(assert false: never)'.=C2=A0 However, there are no (closed) *valu= es* of
type 'never'.

> Unfortunately, the compiler still doesn't realise that, so it
> doesn't help you for pattern-matching.

The gadt-warnings branch, which is described here:

=C2=A0 =C2=A0GADTs and exhaustiveness: looking for the impossible
=C2=A0 =C2=A0Jacques Garrigue's and Jacques Le Normand
=C2=A0 =C2=A0ACM SIGPLAN Workshop on ML, September 2015
=C2=A0 =C2=A0http:/= /www.mlworkshop.org/gadts-and-exhaustiveness-looking-for-the-impossible.pdf=

includes better supports for "empty" types.=C2=A0 For example, he= re's a
definition of an empty type 'wrong':

=C2=A0 =C2=A0type 'a is_true =3D T: [`True] is_true
=C2=A0 =C2=A0type wrong =3D [`False] is_true

and here's a function definition which omits a case that you can
deduce is unmatchable when you know that 'wrong' is empty:

=C2=A0 =C2=A0let f : wrong option -> unit =3D fun None -> ()

The current OCaml compiler (4.02.3) issues a warning for 'f':

=C2=A0 =C2=A0Warning 8: this pattern-matching is not exhaustive.
=C2=A0 =C2=A0Here is an example of a value that is not matched:
=C2=A0 =C2=A0Some _

In contrast, the compiler in the gadt-warnings branch compiles 'f'<= br> without complaint (and generates more efficient code, since there's no<= br> need to inspect the argument).

Jeremy.

--047d7bf109dcd57d7a0522071cf3--