220 18080 <CANh-dXkOqDAH+1u4-phZuev-SKE3KaUzt-U955_S8mm-BHms7w@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "'Jeffrey Yasskin' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Parsing Numbers
Date: Wed, 20 May 2015 15:59:39 -0700
Lines: 72
Approved: news@gmane.org
Message-ID: <CANh-dXkOqDAH+1u4-phZuev-SKE3KaUzt-U955_S8mm-BHms7w@mail.gmail.com>
References: <eb5c19d6-074f-4ee4-8e2d-6d92349eb4be@isocpp.org>
 <555CDDEF.8000002@gmx.net> <CAA7U3HMbniu0_RE2ptbwXzUrP9qRxQ_NG7=fBxytyobJ-X+=Sw@mail.gmail.com>
 <555CEC78.1000208@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1432162807 26190 80.91.229.3 (20 May 2015 23:00:07 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 20 May 2015 23:00:07 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDDM34EO6QDRB4VD6SVAKGQEW7ZW5TI@isocpp.org Thu May 21 01:00:07 2015
Return-path: <std-proposals+bncBDDM34EO6QDRB4VD6SVAKGQEW7ZW5TI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f71.google.com ([209.85.218.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDDM34EO6QDRB4VD6SVAKGQEW7ZW5TI@isocpp.org>)
	id 1YvCy4-0004P3-7s
	for gclcip-std-proposals@m.gmane.org; Thu, 21 May 2015 01:00:04 +0200
Original-Received: by oihf133 with SMTP id f133sf88387384oih.3
        for <gclcip-std-proposals@m.gmane.org>; Wed, 20 May 2015 16:00: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:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=++Y28PgOx4WTEPl7NVQXszzgSJYskCR5tp70X0IpAT4=;
        b=dLbO7IUbwbQYn09+erGUPVVi4O6cOWnMb/immW75RFEgV6FHdOLHYpE1U8KCXLwz9d
         0U7iCwLYdeVbCobBsQRpA2msc0hw1/7ROR5KTKoWfDMgIf3MMFuX1bTEJdfjU8aFh+LO
         HgLI3thPPsrNONOxlmNtWVmJJSvEMk+2HLP/VzXF0kw6OQW8rYsggVT0H4XvWaTZpflw
         s9aKrx10W6YxtDP/Uv/hS50oFBtQchoO+2uwFokA1bcw00BNZzy+WDjgS0WgUQXz/A6D
         CX/QqMiK0VGB7wNmypK7O8rwBRC7OLRWkzU1rAJH47NnzZLsUm/kK6LdKVL6J0YyLPyu
         BcfQ==
X-Gm-Message-State: ALoCoQmCe8q+osouUetX+L0J1fwL+UiyqOSaf5V6vwaZ/l8uIeNfxxEA2JTfPljGo3CjbFPcwEea
X-Received: by 10.42.118.79 with SMTP id w15mr355350icq.2.1432162802781;
        Wed, 20 May 2015 16:00:02 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.47.96 with SMTP id j93ls699868ioo.101.gmail; Wed, 20 May
 2015 16:00:01 -0700 (PDT)
X-Received: by 10.50.221.98 with SMTP id qd2mr242920igc.37.1432162801915;
        Wed, 20 May 2015 16:00:01 -0700 (PDT)
Original-Received: from mail-ig0-x234.google.com (mail-ig0-x234.google.com. [2607:f8b0:4001:c05::234])
        by mx.google.com with ESMTPS id d9si15648730icm.59.2015.05.20.16.00.01
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 20 May 2015 16:00:01 -0700 (PDT)
Received-SPF: pass (google.com: domain of jyasskin@google.com designates 2607:f8b0:4001:c05::234 as permitted sender) client-ip=2607:f8b0:4001:c05::234;
Original-Received: by igbhj9 with SMTP id hj9so2010842igb.1
        for <std-proposals@isocpp.org>; Wed, 20 May 2015 16:00:01 -0700 (PDT)
X-Received: by 10.42.180.73 with SMTP id bt9mr168777icb.83.1432162800679; Wed,
 20 May 2015 16:00:00 -0700 (PDT)
Original-Received: by 10.64.73.2 with HTTP; Wed, 20 May 2015 15:59:39 -0700 (PDT)
In-Reply-To: <555CEC78.1000208@gmail.com>
X-Original-Sender: jyasskin@google.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of jyasskin@google.com designates 2607:f8b0:4001:c05::234 as permitted
 sender) smtp.mail=jyasskin@google.com;       dkim=pass header.i=@google.com;
       dmarc=pass (p=REJECT dis=NONE) header.from=google.com
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: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
X-Original-From: Jeffrey Yasskin <jyasskin@google.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:18080
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18080>

There's a significant risk here that if the proposal is too
complicated, nothing will get accepted.

Jens' suggestion has an advantage that it's clearly sufficient and in
line with the rest of the library, even if the interface might not be
as convenient as some other options. Even the interface, though, isn't
too bad when you look at the code using it.

On Wed, May 20, 2015 at 1:20 PM, Miro Knejp <miro.knejp@gmail.com> wrote:
> The Functional Template Library ( https://github.com/beark/ftl ) has an
> example of monadic parser generators inspired by Haskell.
> https://github.com/beark/ftl/blob/master/docs/Parsec-I.md
>
> Now that library also has overloads of operator>>= and others, which is not
> part of "turn a string into an int" problem, but with all parsing functions
> returning parser monads the composition is much easier to do.
>
> It starts of by introducing the monad itself:
>
> template<typename T>
>     using parser = ftl::eitherT<error,ftl::function<T(std::istream&)>>;
>
>
> and a function to execute the actual parser
>
> template<typename T>
>     ftl::either<error,T> run(parser<T> p, std::istream& is);
>
>
> Each parsing function then returns a parser object.
>
> parser<int> parseNatural();
>
>
> This obviously serves more than a simple "turn a string into an int" but is
> a prime example of composability that really shines with the combining
> operators like >> or << etc. It makes things like this easy
>
> parser<std::vector<int>> parseLispList() {
>     using namesapce ftl;
>     return parseChar('(')
>         >> parseList()
>         << parseChar(')');
> }
>
>
> I thought I'd throw this in just as an example. We had these discussions
> earlier without any consensus and the only new viewpoint brought in this
> time is the functional approach mentioned by Vicente J. Whether this is
> something the standard library can/should follow, or provides the
> performance people need, or it can solve all the use cases people can come
> up with and make everyone happy I don't know.
>
> --
>
> ---
> 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/.

-- 

--- 
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/.

.
