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 2AB8D7EF10 for ; Tue, 24 Feb 2015 19:02:13 +0100 (CET) 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: Pass (mail3-smtp-sop.national.inria.fr: domain of postmaster@ppsw-52.csi.cam.ac.uk designates 131.111.8.152 as permitted sender) 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-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BcAQCAu+xUnJgIb4Nbg1hasEYGkkyFeAKBKkMBAQEBAQEQAQEBAQEICwkJFC6EEAEEAXkFCwsOEyUPAQRJiDoIBNAOhGoBAQgBAQEBHoYHhQyEbgeEKwWTNoVlgRuDFYtJgz6EEG+CQwEBAQ X-IPAS-Result: A0BcAQCAu+xUnJgIb4Nbg1hasEYGkkyFeAKBKkMBAQEBAQEQAQEBAQEICwkJFC6EEAEEAXkFCwsOEyUPAQRJiDoIBNAOhGoBAQgBAQEBHoYHhQyEbgeEKwWTNoVlgRuDFYtJgz6EEG+CQwEBAQ X-IronPort-AV: E=Sophos;i="5.09,639,1418079600"; d="scan'208";a="101187894" Received: from ppsw-52.csi.cam.ac.uk ([131.111.8.152]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Feb 2015 19:02:12 +0100 X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from host86-159-4-23.range86-159.btcentralplus.com ([86.159.4.23]:33719 helo=study.localdomain) by ppsw-52.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (PLAIN:lpw25) (TLSv1.2:AES128-GCM-SHA256:128) id 1YQJoB-0003u6-FJ (Exim 4.82_3-c0e5623) (return-path ); Tue, 24 Feb 2015 18:02:11 +0000 From: Leo White To: "David Allsopp" Cc: "OCaml List" References: <000401d05056$ed605f70$c8211e50$@metastack.com> X-Face: "XWxb[u_Z\PA_Y?9@|IA!!+jTb(/290-*ea/Un$I0B98.$n%eL.;2w*,z]WR#T:,p[ NBd++M7l]#7zj7!{~iw $W-"/=|dVjhT[D{4~gE}gK<2`.6fs!;uqqud]vs2N/3^m7{aS1V, Date: Tue, 24 Feb 2015 18:02:11 +0000 In-Reply-To: <000401d05056$ed605f70$c8211e50$@metastack.com> (David Allsopp's message of "Tue, 24 Feb 2015 17:25:47 -0000") Message-ID: <87wq372noc.fsf@study.localdomain> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Caml-list] Match error with abstract types in modules > Please could someone remind me what it is about types in modules which means > that > > module Foo = struct > type 'a foo > end > > type _ t = A : int Foo.foo t > | B : float Foo.foo t > > let foo A = () > > is non-exhaustive pattern matching, but: > > type 'a bar > > type _ u = C : int bar u > | D : float bar u > > let bar C = () > > is exhaustive? Or is it actually a bug (given that foo B is a type error)? > If Foo is replaced with: module Foo : sig type 'a foo end = struct type 'a foo = unit end so that `int foo` is equal to `float foo`, then your match isn't really exhaustive. In the second version, the compiler cheats. Since `bar` is definied in the same module, it knows that the abstract `bar` type it can see is actually the definition, not just an abstraction of a type defined elsewhere, so it knows that `int bar` cannot equal `float bar`. Personally, I dislike this behaviour and would prefer both cases to give an error. Regards, Leo