From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id 98EA55D6 for ; Fri, 21 Sep 2018 00:10:43 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.54,282,1534802400"; d="scan'208";a="347369394" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 21 Sep 2018 02:10:41 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 931E082503; Fri, 21 Sep 2018 02:10:41 +0200 (CEST) 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 C15AC824CF for ; Fri, 21 Sep 2018 02:10:31 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=garrigue@math.nagoya-u.ac.jp; spf=None smtp.mailfrom=garrigue@math.nagoya-u.ac.jp; spf=None smtp.helo=postmaster@ms.math.nagoya-u.ac.jp IronPort-PHdr: =?us-ascii?q?9a23=3AuNWuZBMgu5pA0pRExSAl6mtUPXoX/o7sNwtQ0KIM?= =?us-ascii?q?zox0Iv7yrarrMEGX3/hxlliBBdydt6obzbKO+4nbGkU4qa6bt34DdJEeHzQksu?= =?us-ascii?q?4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1?= =?us-ascii?q?Ov71GonPhMiryuy+4ZLebxlKiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPde?= =?us-ascii?q?RWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbY?= =?us-ascii?q?UwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0vRz+s87lkRwPpiC?= =?us-ascii?q?cfNj427mfXitBrjKlGpB6tvgFzz5LIbI2QMvd1Y6HTcs4ARWdZQsleWDFPDIO+?= =?us-ascii?q?YIUBAOQPPuhYoZf6qVYVsRu+HAysCP/vyjNUhHL727Ax3eQ7EQHB2QwtB9YAv2?= =?us-ascii?q?7Io9XsKacdT/u1x7TJwzrZdfNWwzb96IfVch8/vPqBWr1wftDLyUk1FgPFgUiQ?= =?us-ascii?q?ppL+MjOQzOsNr2ib4/BmVe21hG4nrAFwrSK2yscxkIXGnJ4axkrG9SVh2Ys4I8?= =?us-ascii?q?CzRk1jYdO8DZdduS+XO5F3T884Xm1ltjo2xqcbtZKmZCQHyJcqywTCZ/GHcIWE?= =?us-ascii?q?+A/vWPiSLDtimX5oeLCyihCv+ka60OL8TNO70FNSoypFjNbMsncN2gTW6sicUP?= =?us-ascii?q?d9+12u2SqP1wzJ7OFLO080la3bKpE727Iwi4Afvl7fESPsmkX2lLeadkQi+ue2?= =?us-ascii?q?9+Tqeqjqq5GSOoNuiwzyKLkil8KjDegiLwQCQnCX+eGm273i+U35Tq9Kjvozkq?= =?us-ascii?q?TBv5DVP94bprS4Aw9az4Ys9Q2yDzK839QEnXkLNlRFdwiIj4juO1DBOun0Deql?= =?us-ascii?q?j1u2jDhn3fLGPqX5DpXXMnfDiKvhfap660NE1AU819Vf55ZNBrEFIfLzQVPxuc?= =?us-ascii?q?fDDh45Ngy02/zoBM981oMYQ2KPA7WWPLncsV+StaoTJLylfosYvn7WLOhts/f0?= =?us-ascii?q?iXI/klgNVaas1JoTLnu/G6I1DV+eZC/Oi9wYDGoR9iU3Vvbrh0CPGWpcbmyoXq?= =?us-ascii?q?0h6xk+AZ6mS4HKSYe8ifmcmi6wWJ9OMDMVQmuQGGvlIt3XE8wHbzifd4o4ymRd?= =?us-ascii?q?BOqRDrQ53BTrjzfUjr9uL+7a4Cod78ux0dFp56vVnB415DUxEoKU2CePVzMsxz?= =?us-ascii?q?9ad3oNxKl65HdF5BKby6Ei2q5dHMBTofVAXQArPNvBieVxTdLqCFqYI4W5DW2+?= =?us-ascii?q?S9DjOgkfC9I8x9hUPxR4AJOnhwzDmSyjDLgEnvmWQpU/tKDEjSD8?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AqAACmNqRblwuCBoVbHAEBAQQBAQcEA?= =?us-ascii?q?QGEQWoSKINziHSNYJhIAQqEbAKDWwYGNBQBAwEBAgEBAQEBEwEBAQEBCBYGTAy?= =?us-ascii?q?CNSQBgl8BAgMjHQEBNwEPCxgCAiYCAlcGLoMGggGiQG+BLoJ1AQEFgXuCchmCA?= =?us-ascii?q?wiBC4l7ggCBOR+CTIR+gwExgiaGSweIFo4ICZAkF4hzhi+SDYJogVmBdk04Oyo?= =?us-ascii?q?BgkE+gVsahlWHW2CODwEB?= X-IPAS-Result: =?us-ascii?q?A0AqAACmNqRblwuCBoVbHAEBAQQBAQcEAQGEQWoSKINziHS?= =?us-ascii?q?NYJhIAQqEbAKDWwYGNBQBAwEBAgEBAQEBEwEBAQEBCBYGTAyCNSQBgl8BAgMjH?= =?us-ascii?q?QEBNwEPCxgCAiYCAlcGLoMGggGiQG+BLoJ1AQEFgXuCchmCAwiBC4l7ggCBOR+?= =?us-ascii?q?CTIR+gwExgiaGSweIFo4ICZAkF4hzhi+SDYJogVmBdk04OyoBgkE+gVsahlWHW?= =?us-ascii?q?2CODwEB?= X-IronPort-AV: E=Sophos;i="5.54,282,1534802400"; d="scan'208";a="347369356" Received: from bsd20.math.nagoya-u.ac.jp (HELO ms.math.nagoya-u.ac.jp) ([133.6.130.11]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 02:10:29 +0200 Received: from [192.168.0.12] (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id C1C978B51E2; Fri, 21 Sep 2018 09:10:26 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=math.nagoya-u.ac.jp; s=20160220; t=1537488626; bh=4JB7NTxfSFwKKSPFBFbFJoDH+TwUgv7UZ4oAGaR1m8o=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=JxoHnMe5dAS49r4Gz96R5BhA4BdXKGIyKFylEuHLftfXGY+i62zoAWwf2jVmooFcZ DYexFHEe2xhZJoguMtwftoRpVJVLwMy/e03xssMKszR4slt9S6ncmsqx0D1pR1Vpks MCWQIB7QDu73um/fZSgLYl8Yeyu4hh4FhvdfXoRE= Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) From: Jacques Garrigue In-Reply-To: Date: Fri, 21 Sep 2018 09:10:25 +0900 Cc: Mailing List OCaml Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Arlen Cox X-Mailer: Apple Mail (2.3445.9.1) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (ms.math.nagoya-u.ac.jp [0.0.0.0]); Fri, 21 Sep 2018 09:10:26 +0900 (JST) X-Virus-Scanned: clamav-milter 0.99.2 at bsdserver20 X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on bsdserver20.math.nagoya-u.ac.jp Subject: Re: [Caml-list] Applicative Functor Madness Reply-To: Jacques Garrigue X-Loop: caml-list@inria.fr X-Sequence: 17078 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A first remark: this use of module type of is probably not a good idea in t= he long term, as module type of is brittle, and its semantics could change. Then why it doesn=E2=80=99t work: for soundness reasons, module aliases to = functor arguments are not allowed, so actually in the body of the functor T= and T_in are not equal, they are just modules with the same signature, so = of course Set.Make(T).t and Set.Make(T_in).t are not equal. A way around this limitation is to remove T from the return type: module Make(T_in : Set.OrderedType) : S with module T :=3D T_in and module ST =3D Set.Make(T_in) =3D struct module ST =3D Set.Make(T_in) end Do you see a problem with this version? Jacques Garrigue On 2018/09/20 23:29, Arlen Cox wrote: >=20 > Hi everyone, >=20 > I'm having some trouble getting some code that relies heavily on applicat= ive functors to type check. Does anyone know what I'm doing wrong with thi= s? >=20 > module type S =3D sig > module T : Set.OrderedType > module ST : module type of Set.Make(T) > end >=20 > module Make(T_in : Set.OrderedType) : S (* <- ERROR *) > with module T =3D T_in > and module ST =3D Set.Make(T_in) > =3D struct > module T =3D T_in > module ST =3D Set.Make(T_in) > end >=20 > I get the following error message referencing the above point in the prog= ram. >=20 > Error: In this `with' constraint, the new definition of ST > does not match its original definition in the constrained signatur= e: > ... > Type declarations do not match: > type t =3D Set.Make(T_in).t > is not included in > type t =3D Set.Make(T).t > File "set.mli", line 68, characters 4-10: Expected declaration > File "set.mli", line 68, characters 4-10: Actual declaration >=20 > It seems to me that since T =3D T_in, but applicative functors should mak= e the type of Set.Make(T) =3D Set.Make(T_in). Does this not work this way? >=20 > Note that if I change the definition of S slightly, the same definition o= f Make now type checks: >=20 > module type S =3D sig > module T : Set.OrderedType > module ST : Set.S with type elt =3D T.t > end >=20 > This solution is undesirable because I have a number of modules whose typ= es would require an excessive number of "with module ... =3D ..." constrain= ts to constrain in this way. Is there a better way of getting this to type= check? >=20 > Thank you, > Arlen >=20 >=20 --=20 Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs=