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 9147B5D5 for ; Wed, 27 Feb 2019 02:00:06 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.58,417,1544482800"; d="scan'208";a="371037586" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 27 Feb 2019 03:00:05 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id 3090A825EF; Wed, 27 Feb 2019 03:00:05 +0100 (CET) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 42B9582581 for ; Wed, 27 Feb 2019 02:59:56 +0100 (CET) Authentication-Results: mail2-smtp-roc.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=3ARNToLhP9R0UegNMRPskl6mtUPXoX/o7sNwtQ0KIM?= =?us-ascii?q?zox0LfvzrarrMEGX3/hxlliBBdydt6oUzbKO+4nbGkU4qa6bt34DdJEeHzQksu?= =?us-ascii?q?4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1?= =?us-ascii?q?Ov71GonPhMiryuy+4ZLebxlLiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPde?= =?us-ascii?q?RWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbY?= =?us-ascii?q?UwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0vRz+s87lkRwPpiC?= =?us-ascii?q?cfNj427mfXitBrjKlGpB6tvgFzz5LIbI2QMvd1Y6HTcs4ARWdZUMhfVzJPDJ6/?= =?us-ascii?q?YYsBAOUOIftXoIvzqFYVsRuyGROhCP/zxjJSmHP727Ax3eQ7EQHB2QwtB9AAv2?= =?us-ascii?q?rSrNroLqcSUOO1x7TVwDXEaPNW3Cr25Y/Ich8/p/GDQKhwccvSyUQ0CwPFiU2Q?= =?us-ascii?q?qYvkPz+PzuQNtG+b7/N6We2zjG4nrhh8rz6yzckvkonEnoMYx1Te+SlkwYs4Jc?= =?us-ascii?q?e0RFN1bNK5Cpdcqi+XOoRwT8g/WW9nojw6xacDuZOjfCgF1pAnxxnHZvOda4iI?= =?us-ascii?q?+BPjVOKLLTdkg3JlYLW/hxeo/Ui4ze38UdC03ExWoSpCl9nArnEN1xrN5cibUv?= =?us-ascii?q?Zw/0Os1SyS2w3S6uxIO104mKTGJ5I737I9mJUevVzGHiDsmUX2iKGWdl8j+uit?= =?us-ascii?q?8+nnYqvpppmBOI9uiwH+Mb8jmtC4AeQgNQgOXnKX+fy71L3k5E31WqlFjvozkq?= =?us-ascii?q?XBqpDVOdwbprKlAw9Syoss9wywDzKi0NgBmXkHLUlFeA6cgojyO1DOJej4Au2l?= =?us-ascii?q?j1Stljdr3fHGMaf7DpXDNHiQ2IvmKJR04FdBxRF74tlF/ZNbF7xJdP36QFXwu8?= =?us-ascii?q?HVJhowLwzyxe/oD8R0k55YUGnJALfPY43Itlrdxu8pL/ONZ8c/vzH4Y6wl6vji?= =?us-ascii?q?l346sUMaZa6om4MQb2n+FfNjdRbKKUHwi8sMRD9Z9jE1S/bn3RjbCWYKNiSCGp?= =?us-ascii?q?kk7zR+M7qISILKR4SjmruEhXnpAppOYWEAEleLCDHjcIDWA65QOhLXGddol3k/?= =?us-ascii?q?bZbkU5UojE/8qAjizLshNu3T42sTspexjIEotd2Wrgk78HlPN+rY02yJSDsuzG?= =?us-ascii?q?oQXT4ymrx4uUt8jE+E1rE+iPtdR4Re?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0ApAgBK7nVc/4aDpUVkDg4BAQEEAQEHB?= =?us-ascii?q?AEBgWWDOyESJ40BjQqaGTgBhEAChBwGBjQSAQMBAQIBAQEBAWwogjopAYJnAQU?= =?us-ascii?q?nEz8QCxgJJQ8dKwYThROsNjOFRIRujF+Bf4N1LopiApFdkggJgkCQHAwZaZIxn?= =?us-ascii?q?nMhgVYzGggbFTuCbJAiWSQwgQUBAZFSAQE?= X-IPAS-Result: =?us-ascii?q?A0ApAgBK7nVc/4aDpUVkDg4BAQEEAQEHBAEBgWWDOyESJ40?= =?us-ascii?q?BjQqaGTgBhEAChBwGBjQSAQMBAQIBAQEBAWwogjopAYJnAQUnEz8QCxgJJQ8dK?= =?us-ascii?q?wYThROsNjOFRIRujF+Bf4N1LopiApFdkggJgkCQHAwZaZIxnnMhgVYzGggbFTu?= =?us-ascii?q?CbJAiWSQwgQUBAZFSAQE?= X-IronPort-AV: E=Sophos;i="5.58,417,1544482800"; d="scan'208";a="371037574" Received: from topoi.pooq.com (HELO april.topoi.pooq.com) ([69.165.131.134]) by mail2-smtp-roc.national.inria.fr with ESMTP; 27 Feb 2019 02:59:54 +0100 Received: by april.topoi.pooq.com (Postfix, from userid 1001) id B4C35C20B2; Tue, 26 Feb 2019 20:59:52 -0500 (EST) Date: Tue, 26 Feb 2019 20:59:52 -0500 From: Hendrik Boom To: Jacques Garrigue Cc: Mailing List OCaml Message-ID: <20190227015952.zvj7fef7fg3ivsnf@topoi.pooq.com> References: <20190226062341.t35u2tz5tole2jyv@topoi.pooq.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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: 17372 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 -> ( Thus *with* the type keyword, but *without* the apostrophes on token1 and phrase1? -- hendrik