Subject: Re: [boost] Interest in an 'either' library?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-06-25 10:27:08
On 06/24/13 22:55, David Sankel wrote:
> On Mon, Jun 24, 2013 at 1:19 PM, Eric Niebler <eniebler_at_[hidden]> wrote:
>> On 13-06-24 11:53 AM, Pierre Talbot wrote:
>>>> This misses what is, IMO, the most important use case of Haskell's
>>>> Either monad: automatic error propagation. This would be more useful if
>>>> there were a way to call a function such that if any of the function's
>>>> arguments were an Either-in-error, the function would immediately return
>>>> the error.
>>>> I implemented something like this. Check out substitution_failure and
>>>> try_call starting here:
>>> In the Expected proposal, there are some methods related to this idea.
> <snip various do-syntax derivatives>
> If we really care about adding a do syntax EDSL, why not make it general
> purpose like Haskell's version so that it can work with any monad and
> compose better with other things?
> either<error, int> result =
> set( _x, getInt ),
> set( _y, getInt ),
> doReturn( pure( _x + _y ) ) );
> If we're going to do that, lets do it generically and completely.
David, is there source code demonstrating this do syntax?
Could you show how to do Eric's example with this do syntax?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk