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 DB4247EE51 for ; Tue, 28 May 2013 10:18:34 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=pra; client-ip=131.111.8.152; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=mailfrom; client-ip=131.111.8.152; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@ppsw-52.csi.cam.ac.uk) identity=helo; client-ip=131.111.8.152; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="postmaster@ppsw-52.csi.cam.ac.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An8BAN9npFGDbwiYnGdsb2JhbABZxUqBBRYOAQEBAQEICwkJFCiCIwEBBAEnEz8FCwsOEyUPAQRJiBoGBLQ7h08WjwcHg1QDrAs X-IPAS-Result: An8BAN9npFGDbwiYnGdsb2JhbABZxUqBBRYOAQEBAQEICwkJFCiCIwEBBAEnEz8FCwsOEyUPAQRJiBoGBLQ7h08WjwcHg1QDrAs X-IronPort-AV: E=Sophos;i="4.87,756,1363129200"; d="scan'208";a="15905889" Received: from ppsw-52.csi.cam.ac.uk ([131.111.8.152]) by mail3-smtp-sop.national.inria.fr with ESMTP; 28 May 2013 10:18:34 +0200 X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from cpc2-cmbg14-2-0-cust33.5-4.cable.virginmedia.com ([86.26.0.34]:59361 helo=netbook) by ppsw-52.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:587) with esmtpsa (PLAIN:lpw25) (TLSv1.2:DHE-RSA-AES128-SHA:128) id 1UhF73-00087Y-FN (Exim 4.80_167-5a66dd3) (return-path ); Tue, 28 May 2013 09:18:33 +0100 From: Leo White To: Erkki Seppala Cc: caml-list@yquem.inria.fr References: <51A38A23.9000402@gmail.com> Date: Tue, 28 May 2013 09:20:04 +0100 In-Reply-To: (Erkki Seppala's message of "Tue, 28 May 2013 09:36:55 +0300") Message-ID: <86ehcrfrd7.fsf@cam.ac.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Caml-list] Recursive fixed polymorphic variants > let rec f = function `B x -> g x | `A -> () > and g = function `B x -> f x | `A -> ();; > > # f (M.b (M.a ())) > - : unit = () > > This gives f (and g) the inferred type ([< `A | `B of [< `A | `B of 'a > ] ] as 'a) -> unit. > > I was under the impression I should be able to describe using the type > variable syntax in function type, but I was unable to. Note that you can use polymorphic recursion to give f a very similar type that also works for this particular example: # let rec f : 'a. ([< `A | `B of ([< `A | `B of 'b ] as 'b) ] as 'a) -> unit = function `B x -> f x | `A -> ();; val f : [< `A | `B of [< `A | `B of 'a ] as 'a ] -> unit = # f (M.b (M.a ()));; - : unit = () Regards, Leo