From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2PG4agg023842 for ; Fri, 25 Mar 2011 17:04:36 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlkAAN+7jE2LEwExkWdsb2JhbACYJY1EAQEBAQkLCwcUBSCITaxKAY45BYVp X-IronPort-AV: E=Sophos;i="4.63,243,1299452400"; d="scan'208";a="79082027" Received: from infao0809.mpi-sb.mpg.de (HELO hera.mpi-sb.mpg.de) ([139.19.1.49]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 25 Mar 2011 17:04:30 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=From:To:In-Reply-To:Subject: References:Message-Id:Content-Type:Content-Transfer-Encoding: Mime-Version:Date:Cc; bh=gT6iuOj8cgi9Ax543T9wCFPOMQ9fNE4R+w5x7c9 J4rs=; b=ES9nAE3KR1dPOIe/y8V32cuRf5ARhvwmomxiNDdnRIIXWbXbJqXsFGO q3tpHhlDPKE4l8rFrptV+yzJGMhMmMQkEhJy9FirZnTq2yLcN+UeHnmYmNx48FFx HSaqDCk7aUtxvm3e6RJm+tePnPBJaCEH85ryT13Kkoaspil1cyJw= Received: from infao0710.mpi-klsb.mpg.de ([139.19.1.27]:52376 helo=zak.mpi-klsb.mpg.de) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1Q39Uw-0007ft-W1; Fri, 25 Mar 2011 17:04:29 +0100 Received: from mnch-5d87b711.pool.mediaways.net ([93.135.183.17]:53639 helo=[192.168.178.21]) by zak.mpi-klsb.mpg.de (envelope-from ) with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) id 1Q39Uw-0005yh-9s; Fri, 25 Mar 2011 17:04:26 +0100 From: Andreas Rossberg To: Joel Reymont In-Reply-To: <87204922-C93B-492A-BDE3-98707F8B30AF@gmail.com> References: <89643D7F-B0F9-4452-BBAF-0445D9D3CA4E@gmail.com> <639CCD2C-402F-4754-B942-B460FD908A95@gmail.com> <63968844-AD95-4359-80F0-E9E071CF6518@mpi-sws.org> <87204922-C93B-492A-BDE3-98707F8B30AF@gmail.com> Message-Id: <21BA03AA-9822-45A7-82E9-2C21482F1C81@mpi-sws.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Date: Fri, 25 Mar 2011 17:04:24 +0100 Cc: caml-list X-Mailer: Apple Mail (2.936) Subject: Re: [Caml-list] Re: module typing issue Well, you have to make it transparent in the Request signature then. Then you should be able to say Req.A -> 1. /Andreas On Mar 25, 2011, at 16.57 h, Joel Reymont wrote: > > On Mar 25, 2011, at 3:46 PM, Andreas Rossberg wrote: > >> I don't think it ever makes sense to define private type >> abbreviations in a structure - they are intended for use in >> signatures. Just drop the private from your example. > > This compiles but fails as soon as I try to replace dispatch in > MyReply (bottom) with > > let dispatch = function | A -> 1 > > This is obvious conceptually as MyReply doesn't know about the > variant type defined in MyRequest. > > How do I make let MyReply know about it? > > Thanks, Joel > > --- x.ml > > module type Message = > sig > type obj > type variant > val make : unit -> obj > (* encapsulate object in a variant type *) > val convert : obj -> variant > val print : obj -> unit > end > > module type Request = > sig > include Message > end > > (* dispatches based on a request *) > > module type Reply = functor (Req : Request) -> > sig > include Message > val dispatch : Req.variant -> obj > end > > module Server (Req : Request) (REP : Reply) = > struct > module Rep = REP(Req) > let server = > while true do > let req = Req.make () in > let var = Req.convert req in > let rep = Rep.dispatch var in > Req.print req; > Rep.print rep > done > end > > module MyRequest : Request = > struct > type obj = int > type variant = A > let make () = 1 > let convert o = A > let print o = () > end > > module MyReply : Reply = functor (Req: Request) -> > struct > type obj = int > type variant = B > let make () = 2 > let convert o = B > let print o = () > let dispatch _ = 2 > end > > module MyServer = Server (MyRequest) (MyReply) > > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb > drivers > ---------------------+------------ > +--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------ > +--------------------------------------- > > > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >