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 36E8D81799 for ; Sun, 28 Jul 2013 02:29:36 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of mathieu.barbin@gmail.com) identity=pra; client-ip=209.85.128.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mathieu.barbin@gmail.com"; x-sender="mathieu.barbin@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of mathieu.barbin@gmail.com designates 209.85.128.54 as permitted sender) identity=mailfrom; client-ip=209.85.128.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mathieu.barbin@gmail.com"; x-sender="mathieu.barbin@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-qe0-f54.google.com) identity=helo; client-ip=209.85.128.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mathieu.barbin@gmail.com"; x-sender="postmaster@mail-qe0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqsCAJxl9FHRVYA2lGdsb2JhbABAGoM7ULUZiDqBEggWDgEBAQEHCwsJEiqCJAEBBAFAARsdAQMBCwYFBAcNLiIBEQEFARwGE4d9AQMJBgwzml2MT4J/g24KGScNZId0AQUMj3EHhAUDl1+BKY4+FimCXIF6IA X-IPAS-Result: AqsCAJxl9FHRVYA2lGdsb2JhbABAGoM7ULUZiDqBEggWDgEBAQEHCwsJEiqCJAEBBAFAARsdAQMBCwYFBAcNLiIBEQEFARwGE4d9AQMJBgwzml2MT4J/g24KGScNZId0AQUMj3EHhAUDl1+BKY4+FimCXIF6IA X-IronPort-AV: E=Sophos;i="4.89,760,1367964000"; d="scan'208";a="22499544" Received: from mail-qe0-f54.google.com ([209.85.128.54]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 28 Jul 2013 02:29:35 +0200 Received: by mail-qe0-f54.google.com with SMTP id 1so1688219qee.27 for ; Sat, 27 Jul 2013 17:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=KwDL73xu7XQWVytKP7doJ9TDG/rRRzDt8lB34nOLYHg=; b=Dhc5YPsYnpruEY0Sz8p79e9p3ocpy5IGwWX8IWrSGgbSGNfGnB9spgRq47/i07y59b p+ulsZpLNP8rQ0sVFVflOfgUmIw8aZ4ZdFLF4a4NphunrR/S3jQ1Kcx3HHHhxL7DNura vOvzP3hIAV1Rpg7sGM4Wp2rryBWaZnYg6NjmfhHmbBIvR/u+86a1h0MeX3A3onQI4tO8 SDU/9bzU2s2A3kHNyOsI4j/KpZLs7b6pn3BI/Z0b2MylyiYQHWS//zIU297kGMeqDDNv Q5UAn0wIMQuxUzNnZOOihYl7Oa+XbpuE1e0CIKt9DPFXPmjqbp+lYlztAwyyx84RIkj9 1nBQ== MIME-Version: 1.0 X-Received: by 10.49.47.103 with SMTP id c7mr3501153qen.49.1374971374057; Sat, 27 Jul 2013 17:29:34 -0700 (PDT) Received: by 10.229.104.70 with HTTP; Sat, 27 Jul 2013 17:29:33 -0700 (PDT) In-Reply-To: <51F2E937.7000809@frisch.fr> References: <51F2E937.7000809@frisch.fr> Date: Sat, 27 Jul 2013 20:29:33 -0400 Message-ID: From: Mathieu Barbin To: Alain Frisch Cc: Gabriel Scherer , caml-list@inria.fr Content-Type: multipart/alternative; boundary=047d7b33d2e253d96904e2877843 Subject: Re: [Caml-list] GADT: question about inference --047d7b33d2e253d96904e2877843 Content-Type: text/plain; charset=ISO-8859-1 Got it. I missed that somehow until now. Indeed using eta expansion to enforce introducing variable-like constructors works well, and looks like a very reasonable work around for the cases I have in mind. Thank you very much for the relevant links and the quick answers. 2013/7/26 Alain Frisch > On 7/26/2013 10:27 PM, Gabriel Scherer wrote: > >> This is explained in the manual (emphasis mine) >> http://caml.inria.fr/pub/docs/**manual-ocaml/manual021.html#**toc85 >> >> The constraints associated to each constructor can be recovered through >>> pattern-matching. >>> Namely, **if the type of the scrutinee of a pattern-matching contains a >>> locally abstract type**, >>> this type can be refined according to the constructor used. >>> >> >> The only types that can be refined by the type equalities introduced >> by GADT are locally abstract types, the variable-like constructor "a" >> introduced by the "(type a)" and "foo : type a . bar" syntaxes. Your >> first two examples have no locally abstract type, only type members of >> modules, so there was no GADT refinement happening. >> > > A feature request related to allowing more kinds of types to be refined by > GADT patterns (abstract types in the current environment, introduced by > unpacking a module -- but the same would be useful for abstract types in a > functor's argument): > > http://caml.inria.fr/mantis/**view.php?id=5713 > > -- Alain > --047d7b33d2e253d96904e2877843 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Got it. I missed that somehow until now. Indeed using eta = expansion to enforce introducing variable-like constructors works well, and= looks like a very reasonable work around for the cases I have in mind.
Thank you very much for the relevant links and the quick answers.


2013/7/26 A= lain Frisch <alain@frisch.fr>
On 7/26/2013 10:27 PM, Gab= riel Scherer wrote:
This is explained in the manual (emphasis mine)
=A0 =A0http://caml.inria.fr/pub/docs/manual-ocaml= /manual021.html#toc85

The constraints associated to each constructor can be recovered through pat= tern-matching.
Namely, **if the type of the scrutinee of a pattern-matching contains a loc= ally abstract type**,
this type can be refined according to the constructor used.

The only types that can be refined by the type equalities introduced
by GADT are locally abstract types, the variable-like constructor "a&q= uot;
introduced by the "(type a)" and "foo : type a . bar" s= yntaxes. Your
first two examples have no locally abstract type, only type members of
modules, so there was no GADT refinement happening.

A feature request related to allowing more kinds of types to be refined by = GADT patterns (abstract types in the current environment, introduced by unp= acking a module -- but the same would be useful for abstract types in a fun= ctor's argument):

http://caml.inria.fr/mantis/view.php?id=3D5713

-- Alain

--047d7b33d2e253d96904e2877843--