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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 5C8747ED45 for ; Mon, 25 Jun 2012 08:44:41 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmoBAN4H6E/RVdW2kGdsb2JhbABEhVqnXYhgCCIBAQEBCQkNBxQEI4IYAQEBAwESAg8dARImAQMBCwEFBQQBBjcCAiEBEgEFARwGEyKHWwMGBZpMCQOLVINAhDknDYlIAQUMikRjhHCBEgOVLoESiXADgx8+gVSCLA X-IronPort-AV: E=Sophos;i="4.77,471,1336341600"; d="scan'208";a="148628075" Received: from mail-yx0-f182.google.com ([209.85.213.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 25 Jun 2012 08:44:40 +0200 Received: by yenl8 with SMTP id l8so3820895yen.27 for ; Sun, 24 Jun 2012 23:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=UGEyWujXfQieWWaI2yPewFdvfqeYhzYra35CoqrDDSA=; b=iuu/h1W9z9Q5Q/HY5N1iF2Sj8mhRiXEMl4yIkxLal1vXraJdTNfR0Os2e/v3BZkpJ9 j/w1viWcdWTmtKcvyPraFsSVijU5KdubLU2auh54vSgOl1Z8ONH146yos0fNhhhP5WUG O8SG3JpnuZNmeVAX0OE4CwujAbXOFpwQcLwPgGC1MlE1e1RawFwTklQ1K8neg61WClUD ChZUo7mConxv1apktjjyetIoEShxFIaFmCy5zKk7iSXZ7y1HkJU070IXG0zQMQXJVfJW f5onOJIapB1sWX8hmKVkS95twkfqBvXOaItavG5sx+0qtCT+ccg2CjCmSXkFcFce50QP cCdQ== Received: by 10.50.236.97 with SMTP id ut1mr7153836igc.50.1340606679445; Sun, 24 Jun 2012 23:44:39 -0700 (PDT) MIME-Version: 1.0 Sender: arnaud.spiwack@gmail.com Received: by 10.64.38.6 with HTTP; Sun, 24 Jun 2012 23:43:59 -0700 (PDT) In-Reply-To: References: From: Arnaud Spiwack Date: Mon, 25 Jun 2012 08:43:59 +0200 X-Google-Sender-Auth: y9UvwOrrFyD75S9WEPeK-2VrGCQ Message-ID: To: bob zhang Cc: Caml List Content-Type: multipart/alternative; boundary=14dae9340b8de970f404c34650ee Subject: Re: [Caml-list] Sharing the code between Monad and MonadState? --14dae9340b8de970f404c34650ee Content-Type: text/plain; charset=UTF-8 I fail to see why you would use first class modules for that. What you are "really" trying to use are just functors. Granted the syntax for functors is awful. But if you are not willing to bear with it, then you would expect to have some boilerplate. That said, your types monad and monad_state are the types of a particular monad and a particular state monad (which have certain initiality property). There is no reason for them to be related, which may also be the cause of code duplication. Arnaud Spiwack On 23 June 2012 16:32, bob zhang wrote: > Hi List, > Given the syntax of first class module is improved a lot. I try to > encode Monad and MonadState, http://ideone.com/HgG4M > Unfortunately I found it's still impossible to share the code between > differrent Monad Instances. Is it theoretically impossible or I missed > something? > Many thanks > > -- > -- Bob > --14dae9340b8de970f404c34650ee Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I fail to see why you would use first class modules for that. What you are = "really" trying to use are just functors. Granted the syntax for = functors is awful. But if you are not willing to bear with it, then you wou= ld expect to have some boilerplate. That said, your types monad and monad_s= tate are the types of a particular monad and a particular state monad (whic= h have certain initiality property). There is no reason for them to be rela= ted, which may also be the cause of code duplication.


Arnaud Spiwack


On 23 June 201= 2 16:32, bob zhang <bobzhang1988@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex"> Hi List,
=C2=A0 =C2=A0Given the syntax of first class module is improve= d a lot. I try to encode Monad and MonadState, =C2=A0http://ideone.com/HgG4M
Unfor= tunately I found it's still impossible to share the code between differ= rent Monad Instances. Is it theoretically impossible or I missed something?=
=C2=A0 =C2=A0Many thanks

--
-- Bob

--14dae9340b8de970f404c34650ee--