From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2PFknno022555 for ; Fri, 25 Mar 2011 16:46:52 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlkAAO23jE2LEwExkWdsb2JhbACYJY1EAQEBAQkLCwcUBSCITaxLAY47BYVp X-IronPort-AV: E=Sophos;i="4.63,243,1299452400"; d="scan'208";a="103542491" Received: from infao0809.mpi-sb.mpg.de (HELO hera.mpi-sb.mpg.de) ([139.19.1.49]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 25 Mar 2011 16:46:51 +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=QEVj+BveODGC7nStFGxu1byIQZ0/Xjv8m+SbUin qTZY=; b=pgc+ncNrrzdQLC/YBu9HLUOf83Z5tv92qvx7iViBnTYoqd0KgBPZ/Kz owZiYzMp5sCEgB0U58s67JgxdBgR9Dp8GcTanRWiZzayAap5DAmwU/ZRESXSJgAA L0WJqVtOac3wcvIs8ZrW3/AH2fI+7N53arkBW/leOByWNRe5U5S4= Received: from infao0710.mpi-klsb.mpg.de ([139.19.1.27]:51670 helo=zak.mpi-klsb.mpg.de) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1Q39Ds-0003zh-Lb; Fri, 25 Mar 2011 16:46:51 +0100 Received: from mnch-5d87b711.pool.mediaways.net ([93.135.183.17]:53415 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 1Q39Ds-0005qL-0K; Fri, 25 Mar 2011 16:46:48 +0100 From: Andreas Rossberg To: Joel Reymont In-Reply-To: <639CCD2C-402F-4754-B942-B460FD908A95@gmail.com> References: <89643D7F-B0F9-4452-BBAF-0445D9D3CA4E@gmail.com> <639CCD2C-402F-4754-B942-B460FD908A95@gmail.com> Message-Id: <63968844-AD95-4359-80F0-E9E071CF6518@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 16:46:47 +0100 Cc: caml-list X-Mailer: Apple Mail (2.936) Subject: Re: [Caml-list] Re: module typing issue 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. /Andreas On Mar 25, 2011, at 15.17 h, Joel Reymont wrote: > It appears that I spoke to early as I'm still having trouble with > the implementation of my concept. > > What is it? > > I'm working with ZeroMQ and Thrift. The latter generates messages > using OCaml classes. > > I have request and reply messages in my system and replies are > created (dispatched) based on their request pair. > > A server should not have to know what messages it's dealing with. > > I would like to wrap each message class in a variant, particularly > helpful since some message classes are unions in the original Thrift > DSL but the Thrift OCaml code generator implements them poorly. > > Is my intent clear in the code below and if so how do I make it work? > > Thanks, Joel > > --- error > > File "x.ml", line 56, characters 26-35: > Error: Signature mismatch: > Modules do not match: > sig > type obj = MyRequest.obj > type variant = MyRequest.variant = A > val make : unit -> int > val convert : 'a -> variant > val print : 'a -> unit > end > is not included in > Request > Values do not match: > val make : unit -> int > is not included in > val make : unit -> obj > > --- 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 = > struct > type obj = private int > type variant = A > let make () = 1 > let convert o = A > let print o = () > end > > module MyReply = functor (Req: Request) -> > struct > type obj = private int > type variant = B > let make () = 2 > let convert o = B > let print o = () > let dispatch _ = B > 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 >