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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id DB5AD7ED26 for ; Sun, 10 Jun 2012 11:27:48 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4EAJxn1E+FBoIF/2dsb2JhbABFhVWwDIIYAQEEASMEGQMBNQEBAwsLGAICGA4CAlcGE4gGBKUHboNGAYUciH0BBoEjigSEV4ESiEGMYI97gm8 X-IronPort-AV: E=Sophos;i="4.75,744,1330902000"; d="scan'208";a="162102979" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 Jun 2012 11:27:47 +0200 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id C323C62E6; Sun, 10 Jun 2012 18:27:44 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (camel-172.math.nagoya-u.ac.jp [172.16.254.4]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 9050A40C6; Sun, 10 Jun 2012 18:27:44 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=math.nagoya-u.ac.jp; h= subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=alpha; bh=m4Yj0Y1s5MaRIERKf9slyypaCqw=; b=zUBFdxsY6Nu+bfpoGlgRo61DAnOd /Ef79ApiblB52x/mGbue+N2rpf6HNSNtAW6Ir+EVhiUc8g+Lhoxq4dZYkN2hcTrx slAm+5ixFp1zoHkogVRzmYqazcuY6tH7mKlkdvk61Jkxo42DoNZ5WDQsh7/ukyaA M+hVarxAhHcKdMQ= DomainKey-Signature: a=rsa-sha1; h=Received:Subject:Mime-Version:Content-Type:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=EMxX9zJ+jmm5NBMZqX0/IQavtzM92ho/qZkTlydij22GexzKSmCC1NfckEsbf1mEUIrF3v4yM9vQ6PkH3Q3hV3WYYMlCNhatYy1AZPmfVSBcbnWulQ3fUMxjhF94uUifCmqhtVzYwq8hiirsiouQ669ncCh6Rl1XEoYe7AZ9HfM=; c=nofws; d=math.nagoya-u.ac.jp; q=dns; s=alpha Received: from tet.garrigue.jp (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id 60BA83A13; Sun, 10 Jun 2012 18:27:44 +0900 (JST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=utf-8 From: Jacques Garrigue In-Reply-To: Date: Sun, 10 Jun 2012 18:27:44 +0900 Cc: caml-list Content-Transfer-Encoding: quoted-printable Message-Id: <51DC4853-76E9-4461-A339-659999595504@math.nagoya-u.ac.jp> References: <4FD164E2.4050807@gmail.com> <8D5E880B-79AC-45E1-B866-B83C3D725E36@math.nagoya-u.ac.jp> To: =?utf-8?Q?Milan_Stanojevi=C4=87?= X-Mailer: Apple Mail (2.1084) Subject: Re: [Caml-list] First Class modules -A bug in 4.00? On 2012/06/09, at 5:25, Milan Stanojevi=C4=87 wrote: > On Thu, Jun 7, 2012 at 11:22 PM, Jacques Garrigue > wrote: >> On 2012/06/08, at 11:35, Hongbo Zhang wrote: >>=20 >>> Hi, List >>> I am not sure this is a bug or not? >>>=20 >>> Below is a contrived example: >>> ------------------ >>> module type S =3D sig >>> type t=3Dint >>> module X : sig type u end >>> end >>>=20 >>> let f ( module X : S) (y:X.X.u) =3D >>> 3 >>> -------------------- >>> Error: This pattern matches values of type X.X.u >>> but a pattern was expected which matches values of type X.X.u >>> The type constructor X.X.u would escape its scope >>> -- Thanks >>=20 >> Definitely, this is not a bug. >> Type X.X.u is abstract, and showing it outside (as by taking an argument >> of that type) would be meaningless. >=20 > What do you mean by "abstract type" here? The problem here is that X.X.u is both abstract, and introduced by the pattern (module X : S), and as such is only valid in the scope of X. > For example, I'd call X.t in the following example abstract and it is > perfectly fine to use it as argument. > module X : sig type t end =3D struct type t =3D int end > let f (x : X.t) =3D 3 You can actually get the same error by using a reference: let r =3D ref [];; module X : sig type t end =3D struct type t =3D int end let f (x : X.t) =3D 3 ;; r :=3D [f];; Error: This expression has type X.t -> int but an expression was expected of type X.t -> int The type constructor X.t would escape its scope In case of a usual module definition, references defined before it are out of scope. Jacques Garrigue=