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 p2PFw3Ws023207 for ; Fri, 25 Mar 2011 16:58:03 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYCAKy6jE1KfVK2kGdsb2JhbAClTQgUAQEBAQkJDQcUBCGITZ9TilSCIYUvL4hcAQEDBYVkBIx1g1RzhEI6 X-IronPort-AV: E=Sophos;i="4.63,243,1299452400"; d="scan'208";a="79081592" Received: from mail-wy0-f182.google.com ([74.125.82.182]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 25 Mar 2011 16:57:58 +0100 Received: by wyf23 with SMTP id 23so1872489wyf.27 for ; Fri, 25 Mar 2011 08:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=Ev6BD96Oab+iY40OwCmW/lIqMI3cEr0t3NliHIoGB7k=; b=JARebNOA+oAIt22GzS/xvHWbcRJzJ6NgAJhW0OT2sa8KGaXMpw79j+kMmN5IgCBVnd So8tVBgWfTnoR6TDRzQPYXrR+UP3ePhYJdPTVjhf8YKyRlu06WDZjLrZEvPvwbPRE5nZ 29u/FexZqvkMrnPZkwBRjprYWs0N3aguqWtKo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=dUqbrboA+AxE79Nkqd0fr1jHSBLfd9DOteUucomEYU07Gj26s3WBAAa+yNgUbPaImf 2XKfw3xqEcL9Mm8NbSneoTR/MazrxGihbPNPvRn+yDlwxNYySVRAeAhAR3iO7XpcrlF4 ETE3gKBtfw29Oye1dkQdt1kRPqZ9wvNvEl+FA= Received: by 10.227.72.7 with SMTP id k7mr862873wbj.115.1301068677810; Fri, 25 Mar 2011 08:57:57 -0700 (PDT) Received: from [192.168.0.195] ([95.60.213.7]) by mx.google.com with ESMTPS id o23sm522382wbc.27.2011.03.25.08.57.55 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2011 08:57:56 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Joel Reymont In-Reply-To: <63968844-AD95-4359-80F0-E9E071CF6518@mpi-sws.org> Date: Fri, 25 Mar 2011 15:57:53 +0000 Cc: caml-list Message-Id: <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> To: Andreas Rossberg X-Mailer: Apple Mail (2.1082) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p2PFw3Ws023207 Subject: Re: [Caml-list] Re: module typing issue 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 ---------------------+------------+---------------------------------------