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 B85157F61E for ; Sat, 4 Nov 2017 20:16:18 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=octa@polychoron.fr; spf=Pass smtp.mailfrom=octa@polychoron.fr; spf=None smtp.helo=postmaster@relay4-d.mail.gandi.net Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of octa@polychoron.fr) identity=pra; client-ip=217.70.183.196; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="octa@polychoron.fr"; x-sender="octa@polychoron.fr"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of octa@polychoron.fr designates 217.70.183.196 as permitted sender) identity=mailfrom; client-ip=217.70.183.196; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="octa@polychoron.fr"; x-sender="octa@polychoron.fr"; 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@relay4-d.mail.gandi.net) identity=helo; client-ip=217.70.183.196; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="octa@polychoron.fr"; x-sender="postmaster@relay4-d.mail.gandi.net"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3ARBqH8x0rmBdHiXWksmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?sesTKPad9pjvdHbS+e9qxAeQG96Eu7QZ06L/iOPJZy8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tLw6annrn5jcXHlD7NBFp?= =?us-ascii?q?DuXzAI/bycqthM6o/JiGZA5UjTG9e7R0ZEGxphnYntERhZppKqErzR2PrGEeKL?= =?us-ascii?q?ce/n9hOV/Gx0W03cy35pM2qyk=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CRBADiEP5ZhsS3RtlcHAEBBAEBCgEBh?= =?us-ascii?q?BtrLoN2mTqBfJhXCoQmAYEUAoRXQhUBAQEBAQEBAQEBEgEBAQgLCwgoL4I4IoJ?= =?us-ascii?q?FAQIDIwQLAQVRCQIYAgImAgJXEwgBAYoSEYsFnWeBbTqLEwEBASSBD4IfggeBU?= =?us-ascii?q?oITgwGFEUyCSYJiBaIOgQGCF51chzyWFoE5NYIOfhFJgmWCa4F0jE0BgRABAQE?= X-IPAS-Result: =?us-ascii?q?A0CRBADiEP5ZhsS3RtlcHAEBBAEBCgEBhBtrLoN2mTqBfJh?= =?us-ascii?q?XCoQmAYEUAoRXQhUBAQEBAQEBAQEBEgEBAQgLCwgoL4I4IoJFAQIDIwQLAQVRC?= =?us-ascii?q?QIYAgImAgJXEwgBAYoSEYsFnWeBbTqLEwEBASSBD4IfggeBUoITgwGFEUyCSYJ?= =?us-ascii?q?iBaIOgQGCF51chzyWFoE5NYIOfhFJgmWCa4F0jE0BgRABAQE?= X-IronPort-AV: E=Sophos;i="5.44,343,1505772000"; d="scan'208";a="243423104" Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Nov 2017 20:16:18 +0100 X-Originating-IP: 86.203.189.221 Received: from [192.168.1.18] (AMarseille-655-1-41-221.w86-203.abo.wanadoo.fr [86.203.189.221]) (Authenticated sender: octa@polychoron.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id D777417209A for ; Sat, 4 Nov 2017 20:16:17 +0100 (CET) To: caml-list@inria.fr References: <86o9p2ywgc.fsf@gmail.com> <20171020113815.GD32138@nunchakus.loria.fr> <20171024133026.uovvzdbnamnzoknv@annexia.org> <20171104184401.3el2vbha2tgpvse5@annexia.org> From: octachron Message-ID: Date: Sat, 4 Nov 2017 20:16:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171104184401.3el2vbha2tgpvse5@annexia.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [Caml-list] What if exn was not an open type? On 04/11/2017 19:44, Richard W.M. Jones wrote: > The problem is that the return statement could be called from many > contexts, all with different types. The compiler expects to unify all > these types (as the same type 'b) which is not possible. This issue can be solved by making the type of return more precise, capturing the fact that return always raises:     type 'a return = { return: 'b. 'a -> 'b } [@@unboxed]     let with_return (type b) f =       let exception Return of b in       try f {return = (fun y -> raise (Return y))} with Return y -> y;; It becomes then possible to write     let f () =       with_return (fun {return} ->         if false then return "error";         let a =           match Some "abc" with           | None -> return "another error"           | Some a -> a in         a     ) — octachron.