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 868167F168 for ; Thu, 27 Aug 2015 11:59:57 +0200 (CEST) IronPort-PHdr: 9a23:GWLyUhXuRvRgUToO+pL8Capt8VfV8LGtZVwlr6E/grcLSJyIuqrYZhKFt8tkgFKBZ4jH8fUM07OQ6PC7HzJcqs/R+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq8aVPVkD3Wr1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu2pN5g/GLdRCTBuLns4/taj4RLKSA/K4noHTk0XlABJCk7L9kepcI32t37RtvB8wzWdJc3BbS47VC7qu6xrUh7zlCAfN3g592zYh9ZYkL8eqh+7ox15hYLZNtLGfMFid7/QKItJDVFKWdxcAnRM Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=christoph.hoeger@tu-berlin.de; spf=None smtp.mailfrom=christoph.hoeger@tu-berlin.de; spf=None smtp.helo=postmaster@mail.tu-berlin.de Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=pra; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=mailfrom; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail.tu-berlin.de) identity=helo; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="postmaster@mail.tu-berlin.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CfAABu3t5VnCEHlYJdhFiDI7pTAQmJJTgUAQEBAQEBAQEQAQEBAQEICwkJIS6CHYIwBAsBRTYCBRYLAgsDAgECAUsNBgIBAYgqozSPY5U6gSKSOoFDBZU9lWeRbIFwAQsBNR+BVm+CTQEBAQ X-IPAS-Result: A0CfAABu3t5VnCEHlYJdhFiDI7pTAQmJJTgUAQEBAQEBAQEQAQEBAQEICwkJIS6CHYIwBAsBRTYCBRYLAgsDAgECAUsNBgIBAYgqozSPY5U6gSKSOoFDBZU9lWeRbIFwAQsBNR+BVm+CTQEBAQ X-IronPort-AV: E=Sophos;i="5.17,422,1437429600"; d="scan'208";a="143939715" Received: from mail.tu-berlin.de ([130.149.7.33]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Aug 2015 11:59:56 +0200 X-tubIT-Incoming-IP: 130.149.172.228 Received: from brego.uebb.tu-berlin.de ([130.149.172.228]) by mail.tu-berlin.de (exim-4.76/mailfrontend-7) with esmtpsa [UNKNOWN:AES128-SHA:128] for id 1ZUtyN-0007rR-0F; Thu, 27 Aug 2015 11:59:56 +0200 To: caml users From: =?UTF-8?Q?Christoph_H=c3=b6ger?= Organization: =?UTF-8?Q?Technische_Universit=c3=a4t_Berlin?= Message-ID: <55DEDF9B.5020006@tu-berlin.de> Date: Thu, 27 Aug 2015 11:59:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: [Caml-list] why is this definition less general? Dear all, I found that I can evade the "first occurence unifies" behavior of recursive polymorphic functions by using explicit polymorphic types: utop # let rec a_to_opt : 'a . ('a -> 'a option) = fun x -> None and int_to_opt (i:int) = a_to_opt i and str_to_opt (s:string)= a_to_opt s ;; val a_to_opt : 'a -> 'a option = val int_to_opt : int -> int option = val str_to_opt : bytes -> bytes option = When I try to annotate the type in the body of a_to_opt, however, I get a "less general" error: utop # let rec a_to_opt : 'a . ('a -> 'a option) = fun x -> (None : 'a option) and int_to_opt (i:int) = a_to_opt i and str_to_opt (s:string)= a_to_opt s ;; Error: This definition has type 'a -> 'a option which is less general than 'a0. 'a0 -> 'a0 option Obviously, 'a is bound by its first occurrence in the type annotation, here. Can someone explain this behavior? -- Christoph Höger Technische Universität Berlin Fakultät IV - Elektrotechnik und Informatik Übersetzerbau und Programmiersprachen Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin Tel.: +49 (30) 314-24890 E-Mail: christoph.hoeger@tu-berlin.de