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 C7B8B7F75C for ; Fri, 8 Aug 2014 14:01:18 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=pra; client-ip=130.149.7.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=mailfrom; client-ip=130.149.7.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail.tu-berlin.de) identity=helo; client-ip=130.149.7.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="postmaster@mail.tu-berlin.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmcFAJO75FOClQchXWdsb2JhbABagw1SV7UplzyIYxYFGAsKBxUphDwBRT0WGAMCAQIBMRoNBgIBAYg+oCGlRpQeBZIPhCuNCo80GoFeag X-IPAS-Result: AmcFAJO75FOClQchXWdsb2JhbABagw1SV7UplzyIYxYFGAsKBxUphDwBRT0WGAMCAQIBMRoNBgIBAYg+oCGlRpQeBZIPhCuNCo80GoFeag X-IronPort-AV: E=Sophos;i="5.01,824,1400018400"; d="scan'208";a="88715057" Received: from mail.tu-berlin.de ([130.149.7.33]) by mail2-smtp-roc.national.inria.fr with ESMTP; 08 Aug 2014 14:01:14 +0200 X-tubIT-Incoming-IP: 130.149.172.228 Received: from brego.uebb.tu-berlin.de ([130.149.172.228]) by mail.tu-berlin.de (exim-4.72/mailfrontend-5) with esmtpa for id 1XFirB-0004us-6h; Fri, 08 Aug 2014 14:01:14 +0200 Message-ID: <53E4BC08.4070109@tu-berlin.de> Date: Fri, 08 Aug 2014 14:01:12 +0200 From: =?ISO-8859-15?Q?Christoph_H=F6ger?= Organization: Technische =?ISO-8859-15?Q?Universit=E4t_Berlin?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: caml users X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit Subject: [Caml-list] Monadic classes -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear all, suppose, you have a state monad, i.e. a simple int counter: let next s = (s+1, s) ;; and now you want to make use of that state monad during class construction: class a s = let (s', _x) = next s in let (s'', _y) = next s' in object method x = _x ; method y = _y end ;; class b s = let (s', _z) = next s in object method z = _z end ;; What you can do, is single inheritance: class c s = object inherit a s end ;; (new c 2)#y ;; (* evaluates to: - : int = 3 *) But to have a truly monadic class construction, I would have to _return_ the state from the instantiated class and pass it on to the second class, i.e. something like this: class c s = object s' = inherit a s ; inherit b s' end ;; Is something like this possible in OCaml? regards, Christoph - -- Christoph Höger Technische Universität Berlin Fakultät IV - Elektrotechnik und Informatik Übersetzerbau und Programmiersprachen Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin Tel.: +49 (30) 314-24890 E-Mail: christoph.hoeger@tu-berlin.de -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlPkvAgACgkQhMBO4cVSGS/JewCfStr70tNfURFeVA845HpZjkto 73AAoInnfnHaPtdbbMvCqNVY/yUwuQec =duU4 -----END PGP SIGNATURE-----