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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 6DD127F249 for ; Wed, 31 Oct 2012 12:57:32 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lambda.q.q@gmail.com) identity=pra; client-ip=209.85.217.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="lambda.q.q@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of lambda.q.q@gmail.com designates 209.85.217.182 as permitted sender) identity=mailfrom; client-ip=209.85.217.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="lambda.q.q@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-lb0-f182.google.com) identity=helo; client-ip=209.85.217.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="postmaster@mail-lb0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEBAPUQkVDRVdm2m2dsb2JhbABEhhe9TggjAQEBAQEICQsJFCeCHgEBAQMBEgIPHQE4AQMBCwEFBRoCBSECAg8BBA0TAQUBIhMihW6BZAMJBgScVmIJA4thg0WFECcNiU4BBQyBFIlxhg+BEwOIVIlwgV2BVYsxgzA/gViCPoFf X-IronPort-AV: E=Sophos;i="4.80,687,1344204000"; d="scan'208";a="179676753" Received: from mail-lb0-f182.google.com ([209.85.217.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 31 Oct 2012 12:57:31 +0100 Received: by mail-lb0-f182.google.com with SMTP id b5so1674074lbd.27 for ; Wed, 31 Oct 2012 04:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=aqmNrdXnRp9KLP4RvdRqHq9O+ECUl8afwSpFYyvbHTE=; b=GmhFY1Z6dJn/64mcQFrV+Ow8E/Ny9QwWK5ECaB6jYA5lFD/Ywpbk0QgWFbDNJexU3c mYFZIuZh81Lj3iu9N3ibp700I0uRwOXlCsZDOpYBRdhFUmaT9agcMKkaznMGpLFm8cGN K7tMZoim/PhAaavx41RvcEtlHpkO1sS4RgSQev5dpmrEvVO/jkNX7e3s76xGuiKW6Ql9 k8LqXtn0AeFiXtHVkoSON9dTFOuDeFCVCzgaeNgOGj8CIK3gpFYv6CJkjAb5twlwSj6X RggN5BLbIGHkjgBPJWExDQm0URH2J46H/1CfAD92VV02CHA6445fFY1aXZB0rSDQ7KHw +9vg== Received: by 10.152.104.240 with SMTP id gh16mr33932507lab.56.1351684651253; Wed, 31 Oct 2012 04:57:31 -0700 (PDT) Received: from golf.niidar.ru.niidar.ru ([178.176.101.101]) by mx.google.com with ESMTPS id oz12sm1241165lab.17.2012.10.31.04.57.28 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Oct 2012 04:57:30 -0700 (PDT) Sender: Ivan Gotovchits From: Ivan Gotovchits To: Didier Cassirame Cc: caml-list@inria.fr References: <87625rhu04.fsf@golf.niidar.ru> Date: Wed, 31 Oct 2012 16:02:30 +0400 In-Reply-To: (Didier Cassirame's message of "Wed, 31 Oct 2012 12:09:09 +0100") Message-ID: <87txtahmsp.fsf@golf.niidar.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Higher order functors over tuples Didier Cassirame writes: > Do you wish to have parallel computation done with these modules, or > do you mean that you want them to be combined sequentially? Ideally, computation must be combined arbitrary. It will be nice to have MAP functor, or MAP2 functor, etc.=20 > Thanks to a very recent post, I rediscovered that OCaml can handle module= s as first class values (since ver. 3.12) : > > - you can define types based on module types like this. > > module type M =3D sig ... end > > type m =3D (module M) > > and then you should be able to build simple lists of type m. I've heard that it is possible, but unfortunately I'm stucked with 3.11 ;'( And I'm not still sure that it will work. Need to try it myself =3D) > 3) My intution says that it can be solved with monads (Generator real= ly > incapsulates side effects in a step. Several computation are combined= in > one big chain... ). Am I right? If so, how to implement it in monads? > > I guess that you could use the type above with regular monads too. Hmmm, the problem is that I do not understand monads quite well. So I've solved the task in a =C2=ABmy=C2=BB way. And so I want to know how the prob= lem can (and could it?) be solved with monads, which are considered a common and idiomatic way of solving such problems. > > If you don't have access to that feature, you could perhaps use higher or= der functors? I do use them. I generate a list of modules using higher order functor. For example I build structure of modules [Even, Odd, Even, Odd]=20 with=20 module M =3D Cons(Even)(Cons(Odd)(Cons(Even)(Odd))) Calling ``let m =3D M.create ()'' will build some structure of objects of d= ifferent types. (Their can be more two types of modules). A call to ``M.step m'' will apply ``Even.step'' or ``Odd.step'' to the last objects in a list, and move it to the head. A call ``M.result m'' will return the result of calling ``Even.result m'' or ``Odd.result m'' dependingly on a current type in head of list. --=20 (__)=20 (oo)=20 /------\/=20 / | ||=20=20=20 * /\---/\=20 ~~ ~~=20=20=20 ...."Have you mooed today?"...