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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 117BD7EEFA for ; Fri, 13 Nov 2015 15:24:24 +0100 (CET) IronPort-PHdr: 9a23:qLaCJhUsc8g8m+ALN0dVUuSCUKHV8LGtZVwlr6E/grcLSJyIuqrYZhKOt8tkgFKBZ4jH8fUM07OQ6PC9HzFZqsvc+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq8CVPlwD2Wf1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu2pN5g/GLdRCTBjN2Eu+OXqswPCRE2B/D9UXmwQkxdMRQLY4RfoWpbZvzHgv/Z8wTSXe8b2Hp4uXjH31aBuQR7uwA0OLTI+7SmDkMt1haNdiBm7tgRjxJXZZpqYcvF5e/WOLpshWWNdU5MJBGR6CYSmYt5XAg== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=romain@cryptosense.com; spf=None smtp.mailfrom=romain@cryptosense.com; spf=None smtp.helo=postmaster@4.mo69.mail-out.ovh.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of romain@cryptosense.com) identity=pra; client-ip=46.105.42.102; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain@cryptosense.com"; x-sender="romain@cryptosense.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of romain@cryptosense.com) identity=mailfrom; client-ip=46.105.42.102; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain@cryptosense.com"; x-sender="romain@cryptosense.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@4.mo69.mail-out.ovh.net) identity=helo; client-ip=46.105.42.102; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain@cryptosense.com"; x-sender="postmaster@4.mo69.mail-out.ovh.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B5AADS8UVWnGYqaS5exTeDPYJTAgiBMzwQAQEBAQEBAQEQAQEBAQEICwkJIS6CLYIIAQEEIw8BBTMNEQsYAgIFFgsCAgkDAgECAUUHDAgCiC4BsDOQUwEBCAIhgQGJKIEphUGCNIFEBZZIjgSbaDiCUoFehi4BAQE X-IPAS-Result: A0B5AADS8UVWnGYqaS5exTeDPYJTAgiBMzwQAQEBAQEBAQEQAQEBAQEICwkJIS6CLYIIAQEEIw8BBTMNEQsYAgIFFgsCAgkDAgECAUUHDAgCiC4BsDOQUwEBCAIhgQGJKIEphUGCNIFEBZZIjgSbaDiCUoFehi4BAQE X-IronPort-AV: E=Sophos;i="5.20,287,1444687200"; d="scan'208";a="187397359" Received: from 4.mo69.mail-out.ovh.net ([46.105.42.102]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-GCM-SHA384; 13 Nov 2015 15:24:23 +0100 Received: from mail182.ha.ovh.net (gw6.ovh.net [213.251.189.206]) by mo69.mail-out.ovh.net (Postfix) with SMTP id 281BFFFB0A2 for ; Fri, 13 Nov 2015 15:24:23 +0100 (CET) Received: from localhost (HELO queueout) (127.0.0.1) by localhost with SMTP; 13 Nov 2015 16:24:20 +0200 Received: from alille-655-1-132-116.w83-198.abo.wanadoo.fr (HELO ?192.168.1.15?) (romain@bardou.fr@83.198.207.116) by ns0.ovh.net with SMTP; 13 Nov 2015 16:24:15 +0200 To: caml-list@inria.fr, daniel.buenzli@erratique.ch References: <5645DC49.7050106@tu-berlin.de> <5645E255.5060900@freenet.de> <5645E9B4.9080007@cryptosense.com> From: Romain Bardou Message-ID: <5645F28B.9000708@cryptosense.com> Date: Fri, 13 Nov 2015 15:24:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.3.0 MIME-Version: 1.0 In-Reply-To: <5645E9B4.9080007@cryptosense.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 17478188680208183968 X-Ovh-Remote: 83.198.207.116 (alille-655-1-132-116.w83-198.abo.wanadoo.fr) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: 0 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekhedrheduucetufdoteggodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecu X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekhedrheduucetufdoteggodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecu X-Validation-by: romain@cryptosense.com Subject: Re: [Caml-list] Cyclic type abbreviation On 13/11/2015 14:46, Romain Bardou wrote: > On 13/11/2015 14:37, David Allsopp wrote: >> Mr. Herr wrote: >>> On 13.11.2015 13:49, Christoph Höger wrote: >>>> Dear all, >>>> >>>> why is this type cyclic? >>>> >>>> type node = int * tree * tree >>>> and tree = node option >>>> >>>> I cannot introduce a manifest for the option type, as there is no >>>> Option module (why is that, btw?) - so I would assume option to be >>>> special enough to be handled like any other algebraic data type. >>> type 'a option = None | Some 'a >>> >>> no need for a module, just a simple type. Maybe you confound it with >>> other >>> languages. >>> >>> And cyclic - well, the types are referring to each other. >>> >>> Summary: what is supposedly wrong with it? >> >> I expect that what is wrong is that you can write: >> >> type node = int * tree * tree >> and tree = Some of node >> | None >> >> I don't know why you can't write [and tree = node option] instead. >> >> >> David >> > > Interestingly, this definition is accepted: > > type tree = (int * 'a * 'a) option as 'a > > Here you are helping the type-checker because you give it a "canonical" > representation that it can use when unifying; it no longer has to expand > the type, potentially infinitely. I think the main point is that the > type is isorecursive, but I'm not really an expert on the subject. > My bad, I had actually redefined the option type as a polymorphic variant before: type 'a option = [ `None | `Some of 'a ] and I forgot about it when I tested the definition of tree above. So yeah you can do that with polymorphic variants even though they are kind of type abbreviations. Thanks to Daniel for pointing this out. -- Romain