From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2PEI5gA018955 for ; Fri, 25 Mar 2011 15:18:05 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYCAP6ijE1KfVK2kGdsb2JhbAClTQgUAQEBAQkJDQcUBCGoRIpUgiGFLS+IXAEBAwWFZASMdYNUc4RCOg X-IronPort-AV: E=Sophos;i="4.63,243,1299452400"; d="scan'208";a="94876180" Received: from mail-wy0-f182.google.com ([74.125.82.182]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 25 Mar 2011 15:17:59 +0100 Received: by wyf23 with SMTP id 23so1719803wyf.27 for ; Fri, 25 Mar 2011 07:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:content-type:mime-version:subject:from :in-reply-to:date:content-transfer-encoding:message-id:references:to :x-mailer; bh=QMtSwte1wl91JIa1sGlPjLIft/mm/NgsOH2h8OJT5Ns=; b=Hom0OzxKLVdAMzaOgkOImyF2q4aVXcmr874oA243BYVNI5w+00iF/lSf9HlIUxlR4H HF9/pfuztJf9iPWGY1jEsCKXpL1ymhWQa1Qd7yLHM7McXjJDXav3WBRWUTlZb29lb/OZ y8ECflJ/J5dIg/6Zr+MXX+ascW77CojGlvKIs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=eMkVda9+4uhpxlBM8VjjGFxQgiCRV3hYRTi4ZkfrTPoWzzULffxuW6T+gQClTGUz/R m5tQmrXt2B1fSdQmyR09eV8sCV0pQS+54J81cT8jx39gx1TMtKtGjvEGhwg3Bi6B1Afn 8Yxehhu/XbLCToNQB5a3zNzJ/J0sFLrqw8uoo= Received: by 10.227.154.12 with SMTP id m12mr776549wbw.193.1301062679647; Fri, 25 Mar 2011 07:17:59 -0700 (PDT) Received: from [192.168.0.195] ([95.60.213.7]) by mx.google.com with ESMTPS id u9sm483201wbg.51.2011.03.25.07.17.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2011 07:17:58 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1082) From: Joel Reymont In-Reply-To: Date: Fri, 25 Mar 2011 14:17:55 +0000 Message-Id: <639CCD2C-402F-4754-B942-B460FD908A95@gmail.com> References: <89643D7F-B0F9-4452-BBAF-0445D9D3CA4E@gmail.com> To: caml-list X-Mailer: Apple Mail (2.1082) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p2PEI5gA018955 Subject: [Caml-list] Re: module typing issue 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 ---------------------+------------+---------------------------------------