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 2F93F7ED26 for ; Fri, 8 Jun 2012 17:29:58 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArgBACMZ0k/RVaC0kGdsb2JhbABFDrQ6CCIBAQEBCQkNBxQEI4IYAQEBAwESAhMZARsdAQMBCwYFCw0uIQEBEQEFARwGEyKHWgEDBgWaeAkDjCKCcIRvChknDVeIcQEFDIo5YYYAA5Uein6DID6DRlU X-IronPort-AV: E=Sophos;i="4.75,738,1330902000"; d="scan'208";a="161962815" Received: from mail-gh0-f180.google.com ([209.85.160.180]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 08 Jun 2012 17:29:57 +0200 Received: by ghbz12 with SMTP id z12so1895254ghb.39 for ; Fri, 08 Jun 2012 08:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=wAh5fGJDdELPEhtyMscOFfhI8T4gjZAVl6SnWSfKnWM=; b=DiihCRAAo9i6e+fOLyEIYoYHxiJpfIDaRskL4aP4fDknOlapCiHV7yvWF/V7lLKi06 q4eQWdLXclUCAod9fjmLjcmy0cSXPPqVq64+gf7kBk8suCBh2yDP/2gg5WOt4DI8gnfF q25KsP7b+UEj7IGgOTHpB9msadPoJ9XT+NiKSkeSQSxXGrrATBMbRLH6B46WYyMfUCOt EGckhgebMMB8JyoEhBWriPOzxISQUTzBzvznW4dPFGSlfnLeBuXeVoj1ZaabAVhSp2gg csc1XT/4FLcZTFFSVQ0isqFa5PYJ8XOZUbdsWUNy6tVPwv+VairXSTvcvBsoiTBLmvVZ sr/A== MIME-Version: 1.0 Received: by 10.60.29.72 with SMTP id i8mr4483840oeh.26.1339169396483; Fri, 08 Jun 2012 08:29:56 -0700 (PDT) Received: by 10.182.144.71 with HTTP; Fri, 8 Jun 2012 08:29:56 -0700 (PDT) In-Reply-To: References: <4FD164E2.4050807@gmail.com> <8D5E880B-79AC-45E1-B866-B83C3D725E36@math.nagoya-u.ac.jp> Date: Fri, 8 Jun 2012 11:29:56 -0400 Message-ID: From: bob zhang To: Jacques Garrigue Cc: caml-list Content-Type: multipart/alternative; boundary=e89a8fb1f8062be7ab04c1f7ac0f Subject: Re: [Caml-list] First Class modules -A bug in 4.00? --e89a8fb1f8062be7ab04c1f7ac0f Content-Type: text/plain; charset=ISO-8859-1 Hi, List, This works around the syntax error problem, but still does not work ------------------------------------------------------ module type S1 = sig module Inner : sig type 'a t val add : 'a t -> 'a t -> int end type int_u = int Inner.t end let f1 (type s) (type a) (module Y : S1 with type int_u = a) (y: Y.int_u) = Y.Inner.add y y Jun 8, 2012 at 11:25 AM, bob zhang wrote: > Thanks. it helps. > Here's what I really want, is there any way to walk around if not possible? > > S1 is not written by me. > -------------------------------------------------------------------- > module type S1 = sig > module Inner : sig > type 'a t > val add : 'a t -> 'a t -> int > end > end > > let f1 > (type s) > (type a) > (module Y : S1 with type s Inner.t = a) (y: s Y.Inner.t) = > Y.Inner.add y y > > ------------------------------------------------------------------------------------------------------------ > On Thu, Jun 7, 2012 at 11:22 PM, Jacques Garrigue < > garrigue@math.nagoya-u.ac.jp> wrote: > >> On 2012/06/08, at 11:35, Hongbo Zhang wrote: >> >> > Hi, List >> > I am not sure this is a bug or not? >> > >> > Below is a contrived example: >> > ------------------ >> > module type S = sig >> > type t=int >> > module X : sig type u end >> > end >> > >> > let f ( module X : S) (y:X.X.u) = >> > 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 >> >> 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. >> >> What you might have meant is: >> >> let f (type a) (module X : S with type X.u = a) (y : X.X.u) = 3 >> >> This is typable (but I'm not sure it means anything...) >> >> Jacques Garrigue >> > > > > -- > -- Bob > -- -- Bob --e89a8fb1f8062be7ab04c1f7ac0f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi, List,
=A0 This works around the syntax error p= roblem, but still does not work
---------------------------------= ---------------------
module type S1 =3D sig
=A0 module= Inner =A0: sig
=A0 =A0 type 'a t
=A0 =A0 val add : 'a t -> '= a t -> int=A0
=A0 end
=A0 type int_u =3D int Inner.t=
end=A0

let f1
=A0 =A0 (type s= )
=A0 =A0 (type a)
=A0 =A0 (module Y : S1 =A0with type int_u =3D a) (y: Y.int_u) =3D=A0
=A0 Y.Inner.add y y=A0

Jun 8, 2012 at 11:25 AM, bob zhang <<= a href=3D"mailto:bobzhang1988@gmail.com" target=3D"_blank">bobzhang1988@gma= il.com> wrote:
Thanks. it helps.=
Here's what I really want, is there any way to walk around if not = possible?

S1 is not written by me.
--------------------= ------------------------------------------------
module type S1 =3D sig
=A0 module Inner =A0: sig
= =A0 =A0 type 'a t
=A0 =A0 val add : 'a t -> 'a t -= > int=A0
=A0 end=A0
end=A0

= let f1
=A0 =A0 (type s)
=A0 =A0 (type a)
=A0 =A0 (module Y : S1 with type s Inner.t = =3D a) (y: s Y.Inner.t) =3D
=A0 Y.Inner.add y y=A0
----= ---------------------------------------------------------------------------= -----------------------------
On Thu, Jun 7, 2012 at 11:22 PM, Jacques Garrigu= e <garrigue@math.nagoya-u.ac.jp> wrote:
On 2012/06/08, at 11:35, Hongbo Zhang wrote:

> Hi, List
> =A0I am not sure this is a bug or not?
>
> =A0Below is a contrived example:
> ------------------
> =A0module type S =3D sig
> =A0 =A0type t=3Dint
> =A0 =A0module =A0X : sig type u =A0 end
> =A0end
>
> =A0let f ( module X : S) =A0(y:X.X.u) =3D
> =A03
> --------------------
> Error: This pattern matches values of type X.X.u
> =A0 =A0 =A0but a pattern was expected which matches values of type X.X= .u
> =A0 =A0 =A0The type constructor X.X.u would escape its scope
> -- Thanks

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.

What you might have meant is:

=A0let f (type a) (module X : S with type X.u =3D a) (y : X.X.u) =3D 3

This is typable (but I'm not sure it means anything...)

Jacques Garrigue



<= /div>--
-- Bob



--
-- Bob
--e89a8fb1f8062be7ab04c1f7ac0f--