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 333377EE25 for ; Fri, 25 Oct 2013 00:57:09 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of pjfrey@sympatico.ca) identity=pra; client-ip=65.55.116.21; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pjfrey@sympatico.ca"; x-sender="pjfrey@sympatico.ca"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of pjfrey@sympatico.ca designates 65.55.116.21 as permitted sender) identity=mailfrom; client-ip=65.55.116.21; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pjfrey@sympatico.ca"; x-sender="pjfrey@sympatico.ca"; 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@blu0-omc1-s10.blu0.hotmail.com) identity=helo; client-ip=65.55.116.21; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pjfrey@sympatico.ca"; x-sender="postmaster@blu0-omc1-s10.blu0.hotmail.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtwBAK6kaVJBN3QVnGdsb2JhbABZhzq7YWoWDgEBAQEBBg0JCRQogk8EgQcCJgJviAqYTo8HkluBKY5BglQ1gQ0DkhyMExaPDA X-IPAS-Result: AtwBAK6kaVJBN3QVnGdsb2JhbABZhzq7YWoWDgEBAQEBBg0JCRQogk8EgQcCJgJviAqYTo8HkluBKY5BglQ1gQ0DkhyMExaPDA X-IronPort-AV: E=Sophos;i="4.93,565,1378850400"; d="scan'208";a="31786220" Received: from blu0-omc1-s10.blu0.hotmail.com ([65.55.116.21]) by mail3-smtp-sop.national.inria.fr with ESMTP; 25 Oct 2013 00:57:08 +0200 Received: from BLU0-SMTP16 ([65.55.116.8]) by blu0-omc1-s10.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 24 Oct 2013 15:57:07 -0700 X-TMN: [iFEQ+kfxzORA9Z5S3B9XaIijzcB1MFiB] X-Originating-Email: [pjfrey@sympatico.ca] Message-ID: Received: from [192.168.2.11] ([70.30.87.100]) by BLU0-SMTP16.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 24 Oct 2013 15:57:06 -0700 From: Peter Frey To: caml-list@inria.fr Content-Type: text/plain; charset="UTF-8" Date: Thu, 24 Oct 2013 18:57:04 -0400 MIME-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 24 Oct 2013 22:57:06.0490 (UTC) FILETIME=[5CABD1A0:01CED10C] Subject: [Caml-list] Equality between abstract type definitions Please consider the following two definitions of map which I would have considered equal. exception Empty type 'a t = Cons of 'a * (int -> 'a t) * int let null = Cons( Obj.magic None, (fun _ -> assert false), max_int ) let map (f: 'a -> 'b) (t: 'a t) : 'b t = if t == null then null else match t with (Cons( h, fn, p )) -> let rec aux h1 p1 = try match fn p1 with (Cons (h2,_, p2)) -> (Cons(f h1, aux h2, p2 )) with Empty -> (Cons(f h1, fn, p1)) in aux h p let map : 'a 'b. ( 'a -> 'b ) -> 'a t -> 'b t = fun f t -> if t == null then null else match t with (Cons( h, fn, p )) -> let rec aux h1 p1 = try match fn p1 with (Cons (h2,_, p2)) -> (Cons(f h1, aux h2, 2 )) with Empty -> (Cons(f h1, fn, p1)) in aux h p The second one gives the error below; no surprise. Error: This definition has type 'b. ('b -> 'b) -> 'b t -> 'b t which is less general than 'a 'b. ('a -> 'b) -> 'a t -> 'b t Why is the first definition accepted? Peter Frey