220 10930 <5384FDF2.6060904@hyc.io> article
Path: news.gmane.org!not-for-mail
From: Pierre Talbot <ptalbot@hyc.io>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: N4015: A proposal to add a utility class to
 represent expected monad
Date: Tue, 27 May 2014 23:04:50 +0200
Lines: 57
Approved: news@gmane.org
Message-ID: <5384FDF2.6060904@hyc.io>
References: <94ded66f-1c50-47b9-8a04-b83805443da9@isocpp.org> <0e4dbb0e-0a7e-4164-be4e-60e114b18548@isocpp.org> <5381BCA6.3060803@wanadoo.fr> <1534916.IcxgtEDE2B@drako>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
X-Trace: ger.gmane.org 1401310090 4923 80.91.229.3 (28 May 2014 20:48:10 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 28 May 2014 20:48:10 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH7J5FDT4ERBAMXTGOAKGQEX5MXWZA@isocpp.org Wed May 28 22:48:03 2014
Return-path: <std-proposals+bncBDH7J5FDT4ERBAMXTGOAKGQEX5MXWZA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wg0-f71.google.com ([74.125.82.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDH7J5FDT4ERBAMXTGOAKGQEX5MXWZA@isocpp.org>)
	id 1WpklW-0000We-Jr
	for gclcip-std-proposals@m.gmane.org; Wed, 28 May 2014 22:48:02 +0200
Original-Received: by mail-wg0-f71.google.com with SMTP id m15sf6475814wgh.10
        for <gclcip-std-proposals@m.gmane.org>; Wed, 28 May 2014 13:48:02 -0700 (PDT)
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=1urNzBfaqULWZK+wzuZO8pdZFcDlt6KTpGa4fCicR9A=;
        b=H5+mejlwpcM+kxB+23rvVSeczPPjm3JbuVOr/sCV8g7XeoCeOIUJrYCotnIaztuZzA
         KVZZj5NCRwxls8urHt9cxdoq4B6U9Z5QMGSRFNNQvSJClOZQBuVkxCwnpUeNPpBaZhqT
         /v4TNrpcqqAHOLRd/90uCWULLsBNmX2LqGNoZstq/d8z/x7njaZDX8TI5iLN55376vRe
         Pb1vYDkoIB8V2NXvyH8Sh4OL++mD5qTAkDHFxy7/4TxBgU072M4J5nCMJPML3M3BjM1U
         ZttQgvmPpac/Ju/U1M3z9MKpJ7tJ16VU5mjbJ6DNlWiPgwAM0k7rrsG75AxWPTYs9Aqg
         HZkA==
X-Gm-Message-State: ALoCoQkehpxgqs1+P6bQppztd+AL+otU+HXqRne9YF5+e4bg3/4JGnfre/KCkC6MfvAcCNW8iNo+
X-Received: by 10.180.14.102 with SMTP id o6mr396050wic.0.1401310082187;
        Wed, 28 May 2014 13:48:02 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.87.38 with SMTP id u6ls95613wiz.10.gmail; Wed, 28 May 2014
 13:48:01 -0700 (PDT)
X-Received: by 10.180.72.230 with SMTP id g6mr392682wiv.3.1401310081057;
        Wed, 28 May 2014 13:48:01 -0700 (PDT)
Original-Received: by 10.194.71.195 with SMTP id x3mswju;
        Tue, 27 May 2014 14:04:53 -0700 (PDT)
X-Received: by 10.180.212.77 with SMTP id ni13mr41412084wic.5.1401224693719;
        Tue, 27 May 2014 14:04:53 -0700 (PDT)
Original-Received: from xvm-161-161.ghst.net ([2001:4b98:dc0:47:216:3eff:fe48:3630])
        by mx.google.com with ESMTPS id fs14si19120808wjc.117.2014.05.27.14.04.53
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Tue, 27 May 2014 14:04:53 -0700 (PDT)
Received-SPF: none (google.com: ptalbot@hyc.io does not designate permitted sender hosts) client-ip=2001:4b98:dc0:47:216:3eff:fe48:3630;
Original-Received: from [192.168.1.17] (nsg93-8-88-175-59-164.fbx.proxad.net [88.175.59.164])
	(using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
	(No client certificate requested)
	by xvm-161-161.ghst.net (Postfix) with ESMTPSA id 1B5072C0CF
	for <std-proposals@isocpp.org>; Tue, 27 May 2014 23:04:50 +0200 (CEST)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In-Reply-To: <1534916.IcxgtEDE2B@drako>
X-Original-Sender: ptalbot@hyc.io
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: ptalbot@hyc.io does not designate permitted sender hosts) smtp.mail=ptalbot@hyc.io
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:10930
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/10930>

Hi Ivan,

First of all, thank you for the feedback.

> Exchanging the types would also allow to specify the default value of 
> E to be std::exception_ptr.

std::exception_ptr being the default type for E might not be a good 
idea. Exceptions are a way to handle error but expected is another. The 
only relation between both is that expected provides support to interact 
from and to an existing system or interface living in the exception 
world. For example, error_condition or error_code could often be a 
better choice. Furthermore, I'd not encourage the use of exception where 
they are not required, setting E to std::exception_ptr certainly 
encourage this.

> I'd rather that the api caters to the "happy path" (to quote E. 
> Meijer) than to the failure cases.

This is true, however in practice I suspect that users will use a type 
definition on expected with their own error type:

template <class T>
using expectation = expected<error_condition, T>;

We get back our "happy path" :-)

> As for fmap, this will start the non-generic way of naming. futures 
> have .then, this will have .fmap (and .then?), who knows how the next 
> monad will name its bind operator. (IMO, this should be a part of 
> another proposal, along with the all the stuff that require new 
> core-language things like <-, and catch_exception {})

IMHO, we didn't use fancy names neither we invented any :-) map and bind 
directly comes from the category theory and Haskell. In Haskell, they 
named the 'map' operation 'fmap' because 'map' was already used for list 
and they didn't want to break anything. We don't have this requirement 
in C++ for the member function. 'bind' comes from the monads and 'then' 
comes from the future interface. We provide the three methods since they 
have a different signature (see section 5.9 in the proposal).

> I agree, being accustomed to dot-notation. But, I guess a lot of
> functional developers would beg to differ. 

Note that we add a syntax for a do-notation like in the section 7.1.

Cheers,
Pierre

-- 

--- 
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 email 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-proposals/.

.
