220 8061 <52A36C6C.30507@wanadoo.fr> article
Path: news.gmane.org!not-for-mail
From: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: resumable functions and monads
Date: Sat, 07 Dec 2013 19:43:56 +0100
Lines: 468
Approved: news@gmane.org
Message-ID: <52A36C6C.30507@wanadoo.fr>
References: <bc1ec3e9-46fd-4e57-a852-512c2611714f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------050000080900030105030007"
X-Trace: ger.gmane.org 1386441833 27364 80.91.229.3 (7 Dec 2013 18:43:53 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 7 Dec 2013 18:43:53 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBB3OYRWKQKGQEPQCXEFQ@isocpp.org Sat Dec 07 19:43:59 2013
Return-path: <std-proposals+bncBDH67CONY4PBB3OYRWKQKGQEPQCXEFQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f197.google.com ([209.85.217.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDH67CONY4PBB3OYRWKQKGQEPQCXEFQ@isocpp.org>)
	id 1VpMr8-0006Pl-OY
	for gclcip-std-proposals@m.gmane.org; Sat, 07 Dec 2013 19:43:58 +0100
Original-Received: by mail-lb0-f197.google.com with SMTP id u14sf2775547lbd.4
        for <gclcip-std-proposals@m.gmane.org>; Sat, 07 Dec 2013 10:43:58 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to
         :subject:references:in-reply-to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=Nl84/Ta2P3lkd7BBJvL7t0CxO3+baaQNa7Z2cpPYOZs=;
        b=mcv7myGD+wLCydsmAhCM/FNiQRruShJ4SdROI/umoVtiYeDm7vaf+KuXzm9JYDZzDn
         V+j7UAhc/2iYBtqfyrNk2mKa9xhJDtL1F0STprOHjzpGUQvW01lWU5AUMHCEjFFCl7rs
         Go9Bc5bqc/bzkqIPugPOfTc7kYyv4Q7KO/I/EBqjOXgFwmpu2RzXBYjj57Avl6bekd9E
         hPxp+E27bgpBrPCMXOiRLOW7FTEEs5Alupc4g4MaBAATdSuCuF01n5ycP3GewRl4iAw9
         qxI9AwqF8Nyx3GHmjDOtEzPadMLV0ZU+EELjYxEMxL6Deo33AIHMCn12xOAqRCz/uvf6
         q2YQ==
X-Gm-Message-State: ALoCoQlggcwiZ0KOTYec3nTnQzgF8KqnJhQ0k3HtthAbrOLKliIBHEnSOC/MKCUDJIVpYbc0htib
X-Received: by 10.152.1.37 with SMTP id 5mr4228774laj.3.1386441838280;
        Sat, 07 Dec 2013 10:43:58 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.90.148 with SMTP id bw20ls269425wib.20.gmail; Sat, 07 Dec
 2013 10:43:57 -0800 (PST)
X-Received: by 10.180.39.140 with SMTP id p12mr7820419wik.12.1386441837180;
        Sat, 07 Dec 2013 10:43:57 -0800 (PST)
Original-Received: from smtp.smtpout.orange.fr (smtp09.smtpout.orange.fr. [80.12.242.131])
        by mx.google.com with ESMTP id d7si1289929wiy.3.2013.12.07.10.43.57
        for <std-proposals@isocpp.org>;
        Sat, 07 Dec 2013 10:43:57 -0800 (PST)
Received-SPF: neutral (google.com: 80.12.242.131 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.131;
Original-Received: from iMac-de-Vicente-Botet-Escriba.local ([92.139.34.180])
	by mwinf5d69 with ME
	id yijw1m00G3tBVfg03ijwJV; Sat, 07 Dec 2013 19:43:57 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.1.1
In-Reply-To: <bc1ec3e9-46fd-4e57-a852-512c2611714f@isocpp.org>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.131 is neither permitted nor denied by best guess
 record for domain of vicente.botet@wanadoo.fr) smtp.mail=vicente.botet@wanadoo.fr
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:8061
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8061>

This is a multi-part message in MIME format.
--------------050000080900030105030007
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 07/12/13 15:00, stepik-777@mail.ru a =E9crit :
> I'm reading this proposal:=20
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3722.pdf
> It looks like adding do-notation for monads from Haskell to C++. It=20
> focuses on std::future, but proposes generalization to user defined types=
..
> It is not clear to me how it will be applied to user defined types.=20
> Say, I want to extend it for std::list, will something like this work?
>
> |
> template<typenameA>
> structListMonad:list<A>
> {
> usinglist<A>::list;// inherit constructors
>
> // bind (>>=3D), apply Func to all elements in *this and concatenate resu=
lts
> template<typenameTFunc>
> autothen(TFunc&&Func)
> {
> autoiter =3Dbegin();
> autoNewList=3DFunc(ListMonad<A>({*iter }));
> for(++iter;iter !=3Dend();++iter)
> NewList.splice(NewList.end(),Func(ListMonad<A>({*iter })));
> returnNewList;
> }
>
> // get element from unit list
> constA&get()
> {
> if(size()!=3D1)
> throw"";
> return*begin();
> }
> };
>
> // construct unit list
> template<typenameA>
> ListMonad<A>mreturn(A a)
> {
> returnListMonad<A>({a});
> }
>
> ListMonad<int>computeProducts()resumable
> {
> inta =3Dawait ListMonad({1,2,3});
> intb =3Dawait ListMonad({1,10,100});
> returnmreturn(a*b);
> }
> /* returns list [1, 10, 100, 2, 20, 200, 3, 30, 300], like in Haskell:
> computeProducts =3D do
>     a <- [1, 2, 3]
>     b <- [1, 10, 100]
>     return (a*b)
> */
> |
>
Hi,

I think you have misunderstood the n3722 proposal. await is only=20
applicable to expressions that return a std::future. The expression

|inta =3Dawait ListMonad({1,2,3});


is incorrect as ||ListMonad({1,2,3})| is not a std::future<int>.
||

You can define monad operations to your list without needing to use await.

What is the continuation function that you want to pass to the bind=20
function to obtain the result you expect?
I don't see any bind function call on the Haskell code. Sorry if this is=20
trivial for some one used to work on Hashkell.

Vicente

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--------------050000080900030105030007
Content-Type: text/html; charset=ISO-8859-1

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Le 07/12/13 15:00, <a class="moz-txt-link-abbreviated" href="mailto:stepik-777@mail.ru">stepik-777@mail.ru</a> a
      &eacute;crit&nbsp;:<br>
    </div>
    <blockquote
      cite="mid:bc1ec3e9-46fd-4e57-a852-512c2611714f@isocpp.org"
      type="cite">
      <div dir="ltr">I'm reading this proposal:
        <a class="moz-txt-link-freetext" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3722.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3722.pdf</a><br>
        It looks like adding do-notation for monads from Haskell to C++.
        It focuses on std::future, but proposes generalization to user
        defined types.<br>
        It is not clear to me how it will be applied to user defined
        types. Say, I want to extend it for std::list, will something
        like this work?<br>
        <br>
        <div class="prettyprint" style="background-color: rgb(250, 250,
          250); border-color: rgb(187, 187, 187); border-style: solid;
          border-width: 1px; word-wrap: break-word;"><code
            class="prettyprint">
            <div class="subprettyprint"><span style="color: #008;"
                class="styled-by-prettify">template</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #008;" class="styled-by-prettify">typename</span><span
                style="color: #000;" class="styled-by-prettify"> A</span><span
                style="color: #660;" class="styled-by-prettify">&gt;</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #008;"
                class="styled-by-prettify">struct</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">ListMonad</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">:</span><span
                style="color: #000;" class="styled-by-prettify"> list</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #000;" class="styled-by-prettify">A</span><span
                style="color: #660;" class="styled-by-prettify">&gt;</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">{</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">using</span><span
                style="color: #000;" class="styled-by-prettify"> list</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #000;" class="styled-by-prettify">A</span><span
                style="color: #660;" class="styled-by-prettify">&gt;::</span><span
                style="color: #000;" class="styled-by-prettify">list</span><span
                style="color: #660;" class="styled-by-prettify">;</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #800;" class="styled-by-prettify">//
                inherit constructors</span><span style="color: #000;"
                class="styled-by-prettify"><br>
                <br>
                &nbsp; &nbsp; </span><span style="color: #800;"
                class="styled-by-prettify">// bind (&gt;&gt;=), apply
                Func to all elements in *this and concatenate results</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">template</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #008;" class="styled-by-prettify">typename</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">TFunc</span><span
                style="color: #660;" class="styled-by-prettify">&gt;</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">auto</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #008;" class="styled-by-prettify">then</span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #606;" class="styled-by-prettify">TFunc</span><span
                style="color: #660;" class="styled-by-prettify">&amp;&amp;</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">Func</span><span
                style="color: #660;" class="styled-by-prettify">)</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #660;"
                class="styled-by-prettify">{</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">auto</span><span
                style="color: #000;" class="styled-by-prettify"> iter </span><span
                style="color: #660;" class="styled-by-prettify">=</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #008;" class="styled-by-prettify">begin</span><span
                style="color: #660;" class="styled-by-prettify">();</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">auto</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">NewList</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">=</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">Func</span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #606;" class="styled-by-prettify">ListMonad</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #000;" class="styled-by-prettify">A</span><span
                style="color: #660;" class="styled-by-prettify">&gt;({</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">*</span><span
                style="color: #000;" class="styled-by-prettify">iter </span><span
                style="color: #660;" class="styled-by-prettify">}));</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">for</span><span style="color:
                #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">(++</span><span
                style="color: #000;" class="styled-by-prettify">iter</span><span
                style="color: #660;" class="styled-by-prettify">;</span><span
                style="color: #000;" class="styled-by-prettify"> iter </span><span
                style="color: #660;" class="styled-by-prettify">!=</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #008;" class="styled-by-prettify">end</span><span
                style="color: #660;" class="styled-by-prettify">();</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">++</span><span
                style="color: #000;" class="styled-by-prettify">iter</span><span
                style="color: #660;" class="styled-by-prettify">)</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #606;"
                class="styled-by-prettify">NewList</span><span
                style="color: #660;" class="styled-by-prettify">.</span><span
                style="color: #000;" class="styled-by-prettify">splice</span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #606;" class="styled-by-prettify">NewList</span><span
                style="color: #660;" class="styled-by-prettify">.</span><span
                style="color: #008;" class="styled-by-prettify">end</span><span
                style="color: #660;" class="styled-by-prettify">(),</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">Func</span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #606;" class="styled-by-prettify">ListMonad</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #000;" class="styled-by-prettify">A</span><span
                style="color: #660;" class="styled-by-prettify">&gt;({</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">*</span><span
                style="color: #000;" class="styled-by-prettify">iter </span><span
                style="color: #660;" class="styled-by-prettify">})));</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">return</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">NewList</span><span
                style="color: #660;" class="styled-by-prettify">;</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #660;"
                class="styled-by-prettify">}</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                <br>
                &nbsp; &nbsp; </span><span style="color: #800;"
                class="styled-by-prettify">// get element from unit list</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">const</span><span
                style="color: #000;" class="styled-by-prettify"> A</span><span
                style="color: #660;" class="styled-by-prettify">&amp;</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #008;" class="styled-by-prettify">get</span><span
                style="color: #660;" class="styled-by-prettify">()</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #660;"
                class="styled-by-prettify">{</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">if</span><span style="color:
                #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #000;" class="styled-by-prettify">size</span><span
                style="color: #660;" class="styled-by-prettify">()</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">!=</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #066;" class="styled-by-prettify">1</span><span
                style="color: #660;" class="styled-by-prettify">)</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">throw</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #080;" class="styled-by-prettify">""</span><span
                style="color: #660;" class="styled-by-prettify">;</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">return</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">*</span><span
                style="color: #008;" class="styled-by-prettify">begin</span><span
                style="color: #660;" class="styled-by-prettify">();</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #660;"
                class="styled-by-prettify">}</span><span style="color:
                #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">};</span><span style="color:
                #000;" class="styled-by-prettify"><br>
              </span><span style="color: #000;"
                class="styled-by-prettify"><br>
              </span><span style="color: #800;"
                class="styled-by-prettify">// construct unit list</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #008;"
                class="styled-by-prettify">template</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #008;" class="styled-by-prettify">typename</span><span
                style="color: #000;" class="styled-by-prettify"> A</span><span
                style="color: #660;" class="styled-by-prettify">&gt;</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #606;"
                class="styled-by-prettify">ListMonad</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #000;" class="styled-by-prettify">A</span><span
                style="color: #660;" class="styled-by-prettify">&gt;</span><span
                style="color: #000;" class="styled-by-prettify"> mreturn</span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #000;" class="styled-by-prettify">A a</span><span
                style="color: #660;" class="styled-by-prettify">)</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">{</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">return</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">ListMonad</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #000;" class="styled-by-prettify">A</span><span
                style="color: #660;" class="styled-by-prettify">&gt;({</span><span
                style="color: #000;" class="styled-by-prettify">a</span><span
                style="color: #660;" class="styled-by-prettify">});</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">}</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                <br>
              </span><span style="color: #606;"
                class="styled-by-prettify">ListMonad</span><span
                style="color: #080;" class="styled-by-prettify">&lt;int&gt;</span><span
                style="color: #000;" class="styled-by-prettify">
                computeProducts</span><span style="color: #660;"
                class="styled-by-prettify">()</span><span style="color:
                #000;" class="styled-by-prettify"> resumable<br>
              </span><span style="color: #660;"
                class="styled-by-prettify">{</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">int</span><span style="color:
                #000;" class="styled-by-prettify"> a </span><span
                style="color: #660;" class="styled-by-prettify">=</span><span
                style="color: #000;" class="styled-by-prettify"> await </span><span
                style="color: #606;" class="styled-by-prettify">ListMonad</span><span
                style="color: #660;" class="styled-by-prettify">({</span><span
                style="color: #066;" class="styled-by-prettify">1</span><span
                style="color: #660;" class="styled-by-prettify">,</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #066;" class="styled-by-prettify">2</span><span
                style="color: #660;" class="styled-by-prettify">,</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #066;" class="styled-by-prettify">3</span><span
                style="color: #660;" class="styled-by-prettify">});</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">int</span><span style="color:
                #000;" class="styled-by-prettify"> b </span><span
                style="color: #660;" class="styled-by-prettify">=</span><span
                style="color: #000;" class="styled-by-prettify"> await </span><span
                style="color: #606;" class="styled-by-prettify">ListMonad</span><span
                style="color: #660;" class="styled-by-prettify">({</span><span
                style="color: #066;" class="styled-by-prettify">1</span><span
                style="color: #660;" class="styled-by-prettify">,</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #066;" class="styled-by-prettify">10</span><span
                style="color: #660;" class="styled-by-prettify">,</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #066;" class="styled-by-prettify">100</span><span
                style="color: #660;" class="styled-by-prettify">});</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">return</span><span
                style="color: #000;" class="styled-by-prettify"> mreturn</span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #000;" class="styled-by-prettify">a</span><span
                style="color: #660;" class="styled-by-prettify">*</span><span
                style="color: #000;" class="styled-by-prettify">b</span><span
                style="color: #660;" class="styled-by-prettify">);</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">}</span><span style="color:
                #000;" class="styled-by-prettify"><br>
              </span><span style="color: #800;"
                class="styled-by-prettify">/* returns list [1, 10, 100,
                2, 20, 200, 3, 30, 300], like in Haskell:<br>
                computeProducts = do<br>
                &nbsp; &nbsp; a &lt;- [1, 2, 3]<br>
                &nbsp; &nbsp; b &lt;- [1, 10, 100]<br>
                &nbsp; &nbsp; return (a*b)<br>
                */</span></div>
          </code></div>
        <br>
      </div>
    </blockquote>
    Hi, <br>
    <br>
    I think you have misunderstood the n3722 proposal. await is only
    applicable to expressions that return a std::future. The expression<br>
    <br>
    <code class="prettyprint"><span style="color: #000;"
        class="styled-by-prettify">&nbsp; &nbsp; </span><span style="color:
        #008;" class="styled-by-prettify">int</span><span style="color:
        #000;" class="styled-by-prettify"> a </span><span style="color:
        #660;" class="styled-by-prettify">=</span><span style="color:
        #000;" class="styled-by-prettify"> await </span><span
        style="color: #606;" class="styled-by-prettify">ListMonad</span><span
        style="color: #660;" class="styled-by-prettify">({</span><span
        style="color: #066;" class="styled-by-prettify">1</span><span
        style="color: #660;" class="styled-by-prettify">,</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #066;" class="styled-by-prettify">2</span><span
        style="color: #660;" class="styled-by-prettify">,</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #066;" class="styled-by-prettify">3</span><span
        style="color: #660;" class="styled-by-prettify">});</span><span
        style="color: #000;" class="styled-by-prettify"><br>
        <br>
        <br>
        is incorrect as </span></code><code class="prettyprint"><span
        style="color: #606;" class="styled-by-prettify">ListMonad</span><span
        style="color: #660;" class="styled-by-prettify">({</span><span
        style="color: #066;" class="styled-by-prettify">1</span><span
        style="color: #660;" class="styled-by-prettify">,</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #066;" class="styled-by-prettify">2</span><span
        style="color: #660;" class="styled-by-prettify">,</span><span
        style="color: #000;" class="styled-by-prettify"> </span><span
        style="color: #066;" class="styled-by-prettify">3</span><span
        style="color: #660;" class="styled-by-prettify">})</span></code>
    is not a std::future&lt;int&gt;.<br>
    <code class="prettyprint"><span style="color: #000;"
        class="styled-by-prettify"></span></code><br>
    <br>
    You can define monad operations to your list without needing to use
    await.<br>
    <br>
    What is the continuation function that you want to pass to the bind
    function to obtain the result you expect?<br>
    I don't see any bind function call on the Haskell code. Sorry if
    this is trivial for some one used to work on Hashkell.<br>
    <br>
    Vicente<br>
    <br>
  </body>
</html>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--------------050000080900030105030007--

.
