From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id C6E735D5 for ; Wed, 27 Feb 2019 18:21:42 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.58,420,1544482800"; d="scan'208";a="371194912" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 27 Feb 2019 19:21:21 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id 526E9825EF; Wed, 27 Feb 2019 19:21:21 +0100 (CET) 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 B021A82581 for ; Wed, 27 Feb 2019 19:21:13 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=hendrik@topoi.pooq.com; spf=None smtp.mailfrom=hendrik@topoi.pooq.com; spf=None smtp.helo=postmaster@april.topoi.pooq.com IronPort-PHdr: =?us-ascii?q?9a23=3AUXymlRb3NfeGb5+sO21jCtL/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZoMS6bnLW6fgltlLVR4KTs6sC17KG9fi4EUU7or+5+EgYd5JNUxJXwe?= =?us-ascii?q?43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRp?= =?us-ascii?q?OOv1BpTSj8Oq3Oyu5pHfeQpFiCa+bL9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+?= =?us-ascii?q?RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPC?= =?us-ascii?q?TQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjm58axlVAHnhz?= =?us-ascii?q?sGNz4h8WHYlMpwjL5AoBm8oxBz2pPYbJ2JOPZ7eK7WYNEUSndbXstJWSJPAp2y?= =?us-ascii?q?YZYMAeoPMulXs5TyqVQMohSwHgSsGODixyVUinPqx6A30eIsGhzG0gw6GNIOtW?= =?us-ascii?q?zZotfrO6cUTO+11qjIzTbeZP5L3jf9743IeQ0mrPGMQ71wd9feyVMuFwPGlViQ?= =?us-ascii?q?tYvlPyuS1uQMqWSb9+1gVeW2i2I9tw5xpT2vy94qh4LUhYwV0kjJ+CR9zYovON?= =?us-ascii?q?G1SU52bcS5HJZeqi2WLZZ6T80tTmxupS000KcJuYShcygP0JknxwDQa/iAc4WQ?= =?us-ascii?q?+B3jTPyRITZ8hH5/ZLK/gA6y8U+hyuHmTsm011FKrjNfntbQsXAN0gTf6smBSv?= =?us-ascii?q?Rj4keswTeC2gTJ5u1ZIE05lbDXJ4Mvz7ItjJYfrErOEyDulEXzlqCWd0Ek+uay?= =?us-ascii?q?6+TgZ7Xrvp+cOJFyig7jKKQum8+/DP8kMggJR2ib/uW82Kf7/U3+R7VKl+c6nb?= =?us-ascii?q?XesJDfPcgbvLK2AxdJ0oY/7BayFyup384dnXkDNV5FfBOHj5P1O1zVO/D5DfK/?= =?us-ascii?q?g0y2nztxxvDGOKfhApTXIXTZnrfhZ+U110kJ6gM41M1S/Np7A6sbIf3uVwelu9?= =?us-ascii?q?XCFB42LgGcxu/7CJN734wZSGvKH+mQO+XQqQnbyPgoJrysaYkZojf+Y9Ii4Pum?= =?us-ascii?q?2X80n1MHfKqBwZwPb3H+BvNhOgOSZn+60YRJKnsDogdrFL+is1aFSzMGIi/qB/?= =?us-ascii?q?tttAF+M5qvCML4fq7ohbWA2CmhGZgPODJaDUiLEDHwcIKdHfwLbXDKe5Mzonk/?= =?us-ascii?q?TbGkDrQZ+1S2rgajleh7KfLT+2sAspX6ktNy4r+LzExgxXlPF82Yllq1YSR0k2?= =?us-ascii?q?cPHWVk1bhloEg71lCb1qk+m/tfDJpY4PYbCgo=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0ApAgDN03Zc/4aDpUVkDg4BAQEEAQEHB?= =?us-ascii?q?AEBgWWDXBIng0BIiHmMfJobOAGEQAKEJwYGNBIBAwEBAgEBAQEBbCiCOikBgmc?= =?us-ascii?q?BBSMECwFGEAsYAgIFIQICDx0rBhOFE6wTfDOFRIRngQuLVIF/g3UuiAuCVwKRX?= =?us-ascii?q?pIMCYJAkB4MGWmSM555IYFWMxoIGxU7gmyQIlkkMIEFAQGRPwEB?= X-IPAS-Result: =?us-ascii?q?A0ApAgDN03Zc/4aDpUVkDg4BAQEEAQEHBAEBgWWDXBIng0B?= =?us-ascii?q?IiHmMfJobOAGEQAKEJwYGNBIBAwEBAgEBAQEBbCiCOikBgmcBBSMECwFGEAsYA?= =?us-ascii?q?gIFIQICDx0rBhOFE6wTfDOFRIRngQuLVIF/g3UuiAuCVwKRXpIMCYJAkB4MGWm?= =?us-ascii?q?SM555IYFWMxoIGxU7gmyQIlkkMIEFAQGRPwEB?= X-IronPort-AV: E=Sophos;i="5.58,420,1544482800"; d="scan'208";a="297561708" Received: from topoi.pooq.com (HELO april.topoi.pooq.com) ([69.165.131.134]) by mail3-smtp-sop.national.inria.fr with ESMTP; 27 Feb 2019 19:21:09 +0100 Received: by april.topoi.pooq.com (Postfix, from userid 1001) id 7B3DBC2E98; Wed, 27 Feb 2019 13:21:06 -0500 (EST) Date: Wed, 27 Feb 2019 13:21:06 -0500 From: Hendrik Boom To: Jacques Garrigue Cc: Mailing List OCaml Message-ID: <20190227182106.4ltnpdyz3zqj33ls@topoi.pooq.com> References: <20190226062341.t35u2tz5tole2jyv@topoi.pooq.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [Caml-list] An awkwardness with type parameters Reply-To: Hendrik Boom X-Loop: caml-list@inria.fr X-Sequence: 17374 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, Feb 26, 2019 at 03:39:24PM +0900, Jacques Garrigue wrote: > > 2019/02/26 15:23, Hendrik Boom : > > > > I have a (broken) function definition starting: > > > > let mixfix : 'token1 'phrase1. > > ('token1, 'phrase1, ('token1, 'phrase1) Phrasestream.phrasestream) grammar > > -> ('token1, 'phrase1) parser > > = fun gram -> ( > > ... > > > > It goes o for a hundred-odd lines. > > The type-parameterized types Phrasestream.phrasestream, grammar, and parser > > have been previously defined, and there are also operations defined on these > > types. > > > > The problem I'm having is that the OCaml type-checker ends up identifying > > the type parameters 'token1 an 'phrase1 because of type errors I've made in > > the body of the mixfix function. Somewhere I ended up using an > > operator that's supposed to work on values of type 'token1 > > on a value of type 'phrase1 instead, and identification of 'token1 and > > 'phrase1 is the natural result. > > > > Is there some way of forcing the type checker to treat 'token1 and > > 'phrase1 as different types so that I can get meaningful type errors > > at the point were they occur? > > You can use locally abstract types, which are often used with GADTs but are not > restricted to them: > let mixfix : type token1 phrase1. > (token1, phrase1, (token1, phrase1) Phrasestream.phrasestream) grammar > -> (token1, phrase1) parser > = fun gram -> ( > … > This is the same as the type you wrote, but additionally prevents the types from being > instantiated inside the definition of mixdix. > > Jacques Garrigue Thank you. I've already found the bug, but I made this change and it will keep it from coming back. -- hendrik