From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 3AABB7EE63 for ; Mon, 13 May 2013 14:11:08 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of flux-caml@inside.org) identity=pra; client-ip=130.230.4.42; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="flux@modeemi.cs.tut.fi"; x-sender="flux-caml@inside.org"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of flux@modeemi.cs.tut.fi) identity=mailfrom; client-ip=130.230.4.42; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="flux@modeemi.cs.tut.fi"; x-sender="flux@modeemi.cs.tut.fi"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail.cs.tut.fi) identity=helo; client-ip=130.230.4.42; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="flux@modeemi.cs.tut.fi"; x-sender="postmaster@mail.cs.tut.fi"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlIBAPPXkFGC5gQqlGdsb2JhbABaFoMowUAOAQEBAQkLCQkUBCSCIAEFJxNPCyElDwEEGIhQuw+MS4J6gz8DiRSOGIEmkyE X-IPAS-Result: AlIBAPPXkFGC5gQqlGdsb2JhbABaFoMowUAOAQEBAQkLCQkUBCSCIAEFJxNPCyElDwEEGIhQuw+MS4J6gz8DiRSOGIEmkyE X-IronPort-AV: E=Sophos;i="4.87,662,1363129200"; d="scan'208";a="17140629" Received: from mail.cs.tut.fi ([130.230.4.42]) by mail2-smtp-roc.national.inria.fr with SMTP; 13 May 2013 14:11:07 +0200 Received: from amavis2.cs.tut.fi (amavis2.cs.tut.fi [130.230.4.70]) by mail.cs.tut.fi (Postfix) with ESMTP id 584F9A6 for ; Mon, 13 May 2013 15:11:06 +0300 (EEST) Received: from mail.cs.tut.fi ([130.230.4.42]) by amavis2.cs.tut.fi (amavis2.cs.tut.fi [130.230.4.70]) (amavisd-maia, port 10024) with ESMTP id 21474-24 for ; Mon, 13 May 2013 15:11:05 +0300 (EEST) Received: from modeemi.modeemi.fi (modeemi.modeemi.fi [130.230.72.134]) by mail.cs.tut.fi (Postfix) with SMTP id 810A6A5 for ; Mon, 13 May 2013 15:11:05 +0300 (EEST) Received: from coffee.modeemi.fi (coffee.modeemi.fi [130.230.72.140]) by modeemi.modeemi.fi (Postfix) with ESMTP id 6053118A77 for ; Mon, 13 May 2013 15:11:05 +0300 (EEST) Received: by coffee.modeemi.fi (Postfix, from userid 17990) id 579AA2D60E3; Mon, 13 May 2013 15:11:05 +0300 (EEST) From: Erkki Seppala To: caml-list@yquem.inria.fr References: <20130513094015.GB8366@frosties> Date: Mon, 13 May 2013 15:11:05 +0300 In-Reply-To: <20130513094015.GB8366@frosties> (Goswin von Brederlow's message of "Mon, 13 May 2013 11:40:15 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.2 Subject: Re: [Caml-list] RFH: type / consistency problem Something like this? module Protocol : sig type 'a request type 'a reply type session val issue : session -> 'a request -> 'a type foo_response = { fr_s : string } val foo : string -> foo_response request type bar_response = int val bar : int -> bar request type baz_response = unit val baz : unit -> baz request end = struct type 'a reply = string -> 'a type 'a request = { req_type : int; req_data : string; req_handle : 'a reply } type foo_response = { fr_s : string } let issue session request = send (request.req_type, request.req_data); request.req_handle (receive ()) let foo int = let handle_foo_response str = { fr_s = str } in { req_type = 42; req_data = Printf.sprintf "hello %d" int; req_handle = handle_foo_response } (* etc *) end The nice thing about this is that you can support synchronous and asynchronous communication with essentially the same interface of constructing messages, you just have a different kind of issue function. -- _____________________________________________________________________ / __// /__ ____ __ http://www.modeemi.fi/~flux/\ \ / /_ / // // /\ \/ / \ / /_/ /_/ \___/ /_/\_\@modeemi.fi \/