Topic: Currying or Partial Application


Author: Sarfaraz Nawaz <nawazzz@gmail.com>
Date: Sat, 6 Jan 2018 06:12:20 -0800 (PST)
Raw View
------=_Part_8441_1957640171.1515247940469
Content-Type: multipart/alternative;
 boundary="----=_Part_8442_679882322.1515247940470"

------=_Part_8442_679882322.1515247940470
Content-Type: text/plain; charset="UTF-8"


As C++ is becoming more functional with its each release, I think we should
also think in the direction of function partial application.

Here is one syntax (inspired from Scala):


int f(int a)(int b)(int c)  // #1
{
   return a + b + c;
}


f(10, 20, 30); // normal. full application

f(10, 20)(30); // partial application

f(10)(20, 30); // partial application

f(10)(20)(30); // partial application



Now what if we have an overload function like:


int f(int a)(std::string b)(int c)  // #2
{
  //...
}



then `f(10)` is ambiguous. In that case, we could disambiguate as:


auto f1 = f(10)(int); //Or  auto f1 = f(10) :: (int) ... stealing from
Haskell?

f1(20, 30); // calls #1

auto f2 = f(10)(std::string);

f2("Might work")(20); //calls #2




Thoughts?

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/835cc86a-2e6c-4e17-aec7-4f16cf8b085f%40isocpp.org.

------=_Part_8442_679882322.1515247940470
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><br></div><div>As C++ is becoming more functional wit=
h its each release, I think we should also think in the direction of functi=
on partial application.</div><div><br></div><div>Here is one syntax (inspir=
ed from Scala):</div><br><div class=3D"prettyprint" style=3D"background-col=
or: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: sol=
id; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> c</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// #1</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">+</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> b </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> c</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>f</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">10</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">30=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #800;" class=3D"styled-by-prettify">// normal. full application=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>f<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">10</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)(</span><span style=3D"color: #066;" class=3D"styled-=
by-prettify">30</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">// partial a=
pplication</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br><br>f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">20</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">30</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/ </span><span style=3D"color: rgb(136, 0, 0);"><span style=3D"color: #800;=
" class=3D"styled-by-prettify">partial application</span></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>f</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">10</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">)(</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)(</span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">30</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">// </span><span s=
tyle=3D"color: rgb(136, 0, 0);"><span style=3D"color: #800;" class=3D"style=
d-by-prettify">partial application</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span></div></code></div><div><br><br>Now wha=
t if we have an overload function like:<br><br></div><div class=3D"prettypr=
int" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, =
187, 187); border-style: solid; border-width: 1px; word-wrap: break-word;">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)(</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">)(</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> c</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// #2</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">//...</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br></span></div></code></div><di=
v><span class=3D"styled-by-prettify" style=3D"font-family: monospace; backg=
round-color: rgb(250, 250, 250); color: rgb(102, 102, 0);"><br></span><span=
 class=3D"styled-by-prettify" style=3D"font-family: monospace; background-c=
olor: rgb(250, 250, 250); color: rgb(0, 0, 0);"><br>then `f(10)` is ambiguo=
us. In that case, we could disambiguate as:</span></div><div><span class=3D=
"styled-by-prettify" style=3D"font-family: monospace; background-color: rgb=
(250, 250, 250); color: rgb(0, 0, 0);"><br></span></div><div><span class=3D=
"styled-by-prettify" style=3D"font-family: monospace; background-color: rgb=
(250, 250, 250);"><div class=3D"prettyprint" style=3D"background-color: rgb=
(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bor=
der-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint" style=
=3D""><div class=3D"subprettyprint" style=3D""><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> f1 </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//Or =C2=A0auto f1 =3D f(10) :: (int) ... stealing =
from Haskell?</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br>f1</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><font color=3D"#006666"><span style=3D"color: #066;" class=3D"st=
yled-by-prettify">20</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">30</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// calls #1</span></font><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> f2 </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">10</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">string</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> <br><br>f2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&quot;Might work&quot;</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)(</span><font color=3D"#=
006666"><span style=3D"color: #066;" class=3D"styled-by-prettify">20</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">//calls #2</span></font><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span></div></=
code></div><br><br>Thoughts?<br><br></span></div></div>

<p></p>

-- <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 e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/835cc86a-2e6c-4e17-aec7-4f16cf8b085f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/835cc86a-2e6c-4e17-aec7-4f16cf8b085f=
%40isocpp.org</a>.<br />

------=_Part_8442_679882322.1515247940470--

------=_Part_8441_1957640171.1515247940469--

.


Author: Jonathan Coe <jonathanbcoe@gmail.com>
Date: Sat, 6 Jan 2018 15:13:11 +0000
Raw View
--Apple-Mail-426FBF5A-A15F-43F1-A56B-B36C01A4AD04
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



> On 6 Jan 2018, at 14:12, Sarfaraz Nawaz <nawazzz@gmail.com> wrote:
>=20
>=20
> As C++ is becoming more functional with its each release, I think we shou=
ld also think in the direction of function partial application.
>=20
> Here is one syntax (inspired from Scala):
>=20
>=20
> int f(int a)(int b)(int c)  // #1
> {
>    return a + b + c;
> }
>=20
>=20
> f(10, 20, 30); // normal. full application
>=20
> f(10, 20)(30); // partial application
>=20
> f(10)(20, 30); // partial application
>=20
> f(10)(20)(30); // partial application
>=20
>=20
>=20
> Now what if we have an overload function like:
>=20
>=20
> int f(int a)(std::string b)(int c)  // #2
> {
>   //...
> }
>=20
>=20
>=20
> then `f(10)` is ambiguous. In that case, we could disambiguate as:
>=20
>=20
> auto f1 =3D f(10)(int); //Or  auto f1 =3D f(10) :: (int) ... stealing fro=
m Haskell?
>=20
> f1(20, 30); // calls #1
>=20
> auto f2 =3D f(10)(std::string);=20
>=20
> f2("Might work")(20); //calls #2
>=20
>=20
>=20
>=20
> Thoughts?
>=20

Do you have an example of how this would allow one to re-write code in a mo=
re maintainable way? I=E2=80=99m not familiar with Scala or the advantages =
that partial application can bring.

Thanks

Jon

> --=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=
 email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/835cc86a-2e6c-4e17-aec7-4f16cf8b085f%40isocpp.=
org.

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/7A4EE214-FE5B-4EC2-BE9E-23522F55EE5B%40gmail.com=
..

--Apple-Mail-426FBF5A-A15F-43F1-A56B-B36C01A4AD04
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div></div><div><br></div><div><br>On 6=
 Jan 2018, at 14:12, Sarfaraz Nawaz &lt;<a href=3D"mailto:nawazzz@gmail.com=
">nawazzz@gmail.com</a>&gt; wrote:<br><br></div><blockquote type=3D"cite"><=
div><div dir=3D"ltr"><div><br></div><div>As C++ is becoming more functional=
 with its each release, I think we should also think in the direction of fu=
nction partial application.</div><div><br></div><div>Here is one syntax (in=
spired from Scala):</div><br><div class=3D"prettyprint" style=3D"background=
-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style:=
 solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)(</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> c</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp;<=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// #1</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp;</span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">+</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> b </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">+</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> c</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>f</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #066;" class=3D"styled-by-prettify">10</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
30</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">// normal. full applicati=
on</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;=
" class=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)(</span><span style=3D"color: #066;" class=3D"styl=
ed-by-prettify">30</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// partia=
l application</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br>f</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span =
style=3D"color: #066;" class=3D"styled-by-prettify">20</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">30</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// </span><span style=3D"color: rgb(136, 0, 0);"><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">partial application</span></span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br>f</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">10</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">)(</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)(</span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">30</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">// </span><span s=
tyle=3D"color: rgb(136, 0, 0);"><span style=3D"color: #800;" class=3D"style=
d-by-prettify">partial application</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span></div></code></div><div><br><br>Now wha=
t if we have an overload function like:<br><br></div><div class=3D"prettypr=
int" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, =
187, 187); border-style: solid; border-width: 1px; word-wrap: break-word;">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)(</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">)(</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> c</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> &nbsp;</span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// #2</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">//...</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br></span></div></code></div><di=
v><span class=3D"styled-by-prettify" style=3D"font-family: monospace; backg=
round-color: rgb(250, 250, 250); color: rgb(102, 102, 0);"><br></span><span=
 class=3D"styled-by-prettify" style=3D"font-family: monospace; background-c=
olor: rgb(250, 250, 250); color: rgb(0, 0, 0);"><br>then `f(10)` is ambiguo=
us. In that case, we could disambiguate as:</span></div><div><span class=3D=
"styled-by-prettify" style=3D"font-family: monospace; background-color: rgb=
(250, 250, 250); color: rgb(0, 0, 0);"><br></span></div><div><span class=3D=
"styled-by-prettify" style=3D"font-family: monospace; background-color: rgb=
(250, 250, 250);"><div class=3D"prettyprint" style=3D"background-color: rgb=
(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bor=
der-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint" style=
=3D""><div class=3D"subprettyprint" style=3D""><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> f1 </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//Or &nbsp;auto f1 =3D f(10) :: (int) ... stealing =
from Haskell?</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br>f1</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><font color=3D"#006666"><span style=3D"color: #066;" class=3D"st=
yled-by-prettify">20</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">30</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// calls #1</span></font><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> f2 </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">10</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">string</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> <br><br>f2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">"Might work"</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">)(</span><font color=3D"#006666"><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">20</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">//calls #2</span></font><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br><br></span></div></code></div=
><br><br>Thoughts?<br><br></span></div></div></div></blockquote><div><br></=
div><div>Do you have an example of how this would allow one to re-write cod=
e in a more maintainable way? I=E2=80=99m not familiar with Scala or the ad=
vantages that partial application can bring.</div><div><br></div><div>Thank=
s</div><div><br></div><div>Jon</div><br><blockquote type=3D"cite"><div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/835cc86a-2e6c-4e17-aec7-4f16cf8b085f%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/835cc86a-2e6c-4e17-aec7-4f16cf8b=
085f%40isocpp.org</a>.<br>
</div></blockquote></body></html>

<p></p>

-- <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 e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7A4EE214-FE5B-4EC2-BE9E-23522F55EE5B%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7A4EE214-FE5B-4EC2-BE9E-23522F55EE5B%=
40gmail.com</a>.<br />

--Apple-Mail-426FBF5A-A15F-43F1-A56B-B36C01A4AD04--

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Sat, 6 Jan 2018 15:44:26 +0000
Raw View
--001a11c1418cab408705621d707f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I love the functional direction of template metaprogramming and I certainly
support more functional concepts in the core language. Partial application
is nice, and the general idea of implanting that into C++ is something I
support.

A key feature that you're avoiding here is that of flipping parameters so
you can pre-fill the 1st and 3rd parameter and return a function accepting
the second parameter and returning the fully evaluated expression - I think
this should be a key part of your proposal. Limiting the partial
application abilities because of some arbitrary parameter order would be
rather frustrating/

I don't think there's any point in defining the function any differently
from a normal function (i.e. parameters in different sets of parentheses).
If you can utilise partial application at all, then I believe that there is
no need to restrict it to functions defined in a very specific way,
especially when we already have so many libraries that declare functions in
the usual way.

Rather than having special syntax at all, it'd first make sense if you can
explore the idea of wrapping this in some kind of existing structure. For
example, a class encapsulating a function call, where each call recursively
produces a sub-class expecting the next parameter until the class with only
one remaining parameter, which returns the final result upon the operator()
call. You'd stand a *much *better chance doing it that way than changing
the underlying language. Fortunately there are already some minor efforts
towards this, e.g. https://vittorioromeo.info/index/blog/cpp17_curry.html -
*also* make sure you look at std::bind, as it is quite relevant here.

On Sat, Jan 6, 2018 at 3:13 PM, Jonathan Coe <jonathanbcoe@gmail.com> wrote=
:

> Do you have an example of how this would allow one to re-write code in a
> more maintainable way? I=E2=80=99m not familiar with Scala or the advanta=
ges that
> partial application can bring.
>
> Thanks
>
> Jon
>

There is a lot of beauty to be found, but at the same time it introduces a
different approach to thinking about problems. Here's an immediate example
from the above link that is already pretty nice (although it CAN be done
with lambdas, more complex examples get ugly fast):

std::vector<std::string> names{/* ... */}
auto find_in_names =3D
    curried_find(std::begin(names))(std::end(names));
auto jack =3D find_in_names("Jack");auto rose =3D find_in_names("Rose");

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAC%2B0CCNuADCqfhgtS60vpKvnggww1BQC9xVwAPrTBx%2B=
_CDcapA%40mail.gmail.com.

--001a11c1418cab408705621d707f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><br></div>I love the functional direction of template=
 metaprogramming and I certainly support more functional concepts in the co=
re language. Partial application is nice, and the general idea of implantin=
g that into C++ is something I support.<br><br>A key feature that you&#39;r=
e avoiding here is that of flipping parameters so you can pre-fill the 1st =
and 3rd parameter and return a function accepting the second parameter and =
returning the fully evaluated expression - I think this should be a key par=
t of your proposal. Limiting the partial application abilities because of s=
ome arbitrary parameter order would be rather frustrating/<div><br>I don&#3=
9;t think there&#39;s any point in defining the function any differently fr=
om a normal function (i.e. parameters in different sets of parentheses). If=
 you can utilise partial application at all, then I believe that there is n=
o need to restrict it to functions defined in a very specific way, especial=
ly when we already have so many libraries that declare functions in the usu=
al way.<br><br>Rather than having special syntax at all, it&#39;d first mak=
e sense if you can explore the idea of wrapping this in some kind of existi=
ng structure. For example, a class encapsulating a function call, where eac=
h call recursively produces a sub-class expecting the next parameter until =
the class with only one remaining parameter, which returns the final result=
 upon the operator() call. You&#39;d stand a <b>much </b>better chance doin=
g it that way than changing the underlying language. Fortunately there are =
already some minor efforts towards this, e.g.=C2=A0<a href=3D"https://vitto=
rioromeo.info/index/blog/cpp17_curry.html">https://vittorioromeo.info/index=
/blog/cpp17_curry.html</a> - <i>also</i>=C2=A0make sure you look at std::bi=
nd, as it is quite relevant here.<br><div class=3D"gmail_extra"><br><div cl=
ass=3D"gmail_quote">On Sat, Jan 6, 2018 at 3:13 PM, Jonathan Coe <span dir=
=3D"ltr">&lt;<a href=3D"mailto:jonathanbcoe@gmail.com" target=3D"_blank">jo=
nathanbcoe@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,20=
4);padding-left:1ex"><div dir=3D"auto"><span class=3D"gmail-"><div></div><d=
iv>Do you have an example of how this would allow one to re-write code in a=
 more maintainable way? I=E2=80=99m not familiar with Scala or the advantag=
es that partial application can bring.<br></div></span><div><br></div><div>=
Thanks</div><div><br></div><div>Jon</div></div></blockquote></div><br>There=
 is a lot of beauty to be found, but at the same time it introduces a diffe=
rent approach to thinking about problems. Here&#39;s an immediate example f=
rom the above link that is already pretty nice (although it CAN be done wit=
h lambdas, more complex examples get ugly fast):<br><br><pre style=3D"color=
:rgb(0,0,0);background-image:initial;background-position:initial;background=
-size:initial;background-repeat:initial;background-origin:initial;backgroun=
d-clip:initial"><span style=3D"color:rgb(102,102,22)">std</span><span style=
=3D"color:rgb(128,0,128)">::</span><span style=3D"color:rgb(96,48,0)">vecto=
r</span><span style=3D"color:rgb(128,0,128)">&lt;</span><span style=3D"colo=
r:rgb(102,102,22)">std</span><span style=3D"color:rgb(128,0,128)">::</span>=
<span style=3D"color:rgb(96,48,0)">string</span><span style=3D"color:rgb(12=
8,0,128)">&gt;</span> names<span style=3D"color:rgb(128,0,128)">{</span><sp=
an style=3D"color:rgb(105,105,105)">/* ... */</span><span style=3D"color:rg=
b(128,0,128)">}</span>

<span style=3D"color:rgb(128,0,0);font-weight:bold">auto</span> find_in_nam=
es <span style=3D"color:rgb(128,128,48)">=3D</span>=20
    curried_find<span style=3D"color:rgb(128,128,48)">(</span><span style=
=3D"color:rgb(102,102,22)">std</span><span style=3D"color:rgb(128,0,128)">:=
:</span>begin<span style=3D"color:rgb(128,128,48)">(</span>names<span style=
=3D"color:rgb(128,128,48)">)</span><span style=3D"color:rgb(128,128,48)">)<=
/span><span style=3D"color:rgb(128,128,48)">(</span><span style=3D"color:rg=
b(102,102,22)">std</span><span style=3D"color:rgb(128,0,128)">::</span>end<=
span style=3D"color:rgb(128,128,48)">(</span>names<span style=3D"color:rgb(=
128,128,48)">)</span><span style=3D"color:rgb(128,128,48)">)</span><span st=
yle=3D"color:rgb(128,0,128)">;</span>

<span style=3D"color:rgb(128,0,0);font-weight:bold">auto</span> jack <span =
style=3D"color:rgb(128,128,48)">=3D</span> find_in_names<span style=3D"colo=
r:rgb(128,128,48)">(</span><span style=3D"color:rgb(128,0,0)">&quot;</span>=
<span style=3D"color:rgb(0,0,230)">Jack</span><span style=3D"color:rgb(128,=
0,0)">&quot;</span><span style=3D"color:rgb(128,128,48)">)</span><span styl=
e=3D"color:rgb(128,0,128)">;</span>
<span style=3D"color:rgb(128,0,0);font-weight:bold">auto</span> rose <span =
style=3D"color:rgb(128,128,48)">=3D</span> find_in_names<span style=3D"colo=
r:rgb(128,128,48)">(</span><span style=3D"color:rgb(128,0,0)">&quot;</span>=
<span style=3D"color:rgb(0,0,230)">Rose</span><span style=3D"color:rgb(128,=
0,0)">&quot;</span><span style=3D"color:rgb(128,128,48)">)</span><span styl=
e=3D"color:rgb(128,0,128)">;</span></pre></div></div></div>

<p></p>

-- <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 e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCNuADCqfhgtS60vpKvnggww1BQC9x=
VwAPrTBx%2B_CDcapA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCNuAD=
CqfhgtS60vpKvnggww1BQC9xVwAPrTBx%2B_CDcapA%40mail.gmail.com</a>.<br />

--001a11c1418cab408705621d707f--

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Sat, 6 Jan 2018 16:19:03 +0000
Raw View
--001a1140ab1a6d578805621decb4
Content-Type: text/plain; charset="UTF-8"

On Sat, Jan 6, 2018 at 3:13 PM, Jonathan Coe <jonathanbcoe@gmail.com> wrote:

> Do you have an example of how this would allow one to re-write code in a *more
> maintainable way*?
>

I just realised my example doesn't fit your request for maintainability.
From my experience with Haskell, I can say that it often makes code highly
*reusable*, and there are a lot of very flexible Haskell libraries that are
only a few dozen lines long due to this. Once a handful of basic functions
are in place, they can be used and abused in an incredible variety of ways,
and you don't need to think twice about doing so. A lot of this (not all,
but a lot) is due to partial application and parameter flipping.

So in terms of *reusability,* maintainability can be improved.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMtAos5KpLmvDAkxCNfBFJQQqKrTZh7jfhv6vCKKFbtJw%40mail.gmail.com.

--001a1140ab1a6d578805621decb4
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On S=
at, Jan 6, 2018 at 3:13 PM, Jonathan Coe <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:jonathanbcoe@gmail.com" target=3D"_blank">jonathanbcoe@gmail.com</a>&=
gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 =
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"auto"><span=
 class=3D""><div></div><div>Do you have an example of how this would allow =
one to re-write code in a <i>more maintainable way</i>?</div></span></div><=
/blockquote><div><br>I just realised my example doesn&#39;t fit your reques=
t for maintainability. From my experience with Haskell, I can say that it o=
ften makes code highly <i>reusable</i>, and there are a lot of very flexibl=
e Haskell libraries that are only a few dozen lines long due to this. Once =
a handful of basic functions are in place, they can be used and abused in a=
n incredible variety of ways, and you don&#39;t need to think twice about d=
oing so. A lot of this (not all, but a lot) is due to partial application a=
nd parameter flipping.<br><br>So in terms of <i>reusability,</i>=C2=A0maint=
ainability can be improved.</div></div></div></div>

<p></p>

-- <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 e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMtAos5KpLmvDAkxCNfBFJQQqKrTZ=
h7jfhv6vCKKFbtJw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMtAos5=
KpLmvDAkxCNfBFJQQqKrTZh7jfhv6vCKKFbtJw%40mail.gmail.com</a>.<br />

--001a1140ab1a6d578805621decb4--

.


Author: Jonathan Coe <jonathanbcoe@gmail.com>
Date: Sat, 6 Jan 2018 19:18:55 +0000
Raw View
--Apple-Mail-2421A84B-269F-43DD-BDB5-E116231E05E5
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



> On 6 Jan 2018, at 16:19, Jake Arkinstall <jake.arkinstall@gmail.com> wrot=
e:
>=20
>> On Sat, Jan 6, 2018 at 3:13 PM, Jonathan Coe <jonathanbcoe@gmail.com> wr=
ote:
>> Do you have an example of how this would allow one to re-write code in a=
 more maintainable way?
>=20
> I just realised my example doesn't fit your request for maintainability. =
From my experience with Haskell, I can say that it often makes code highly =
reusable, and there are a lot of very flexible Haskell libraries that are o=
nly a few dozen lines long due to this. Once a handful of basic functions a=
re in place, they can be used and abused in an incredible variety of ways, =
and you don't need to think twice about doing so. A lot of this (not all, b=
ut a lot) is due to partial application and parameter flipping.
>=20
> So in terms of reusability, maintainability can be improved.


Interesting. As you say, the example you give can be done with lambdas; do =
you have an example where lambdas are not a good fit?
> --=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=
 email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/CAC%2B0CCMtAos5KpLmvDAkxCNfBFJQQqKrTZh7jfhv6vC=
KKFbtJw%40mail.gmail.com.

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/1A30B57E-40F5-452C-850C-55AF5F20F073%40gmail.com=
..

--Apple-Mail-2421A84B-269F-43DD-BDB5-E116231E05E5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div></div><div><br></div><div><br>On 6=
 Jan 2018, at 16:19, Jake Arkinstall &lt;<a href=3D"mailto:jake.arkinstall@=
gmail.com">jake.arkinstall@gmail.com</a>&gt; wrote:<br><br></div><blockquot=
e type=3D"cite"><div><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=
=3D"gmail_quote">On Sat, Jan 6, 2018 at 3:13 PM, Jonathan Coe <span dir=3D"=
ltr">&lt;<a href=3D"mailto:jonathanbcoe@gmail.com" target=3D"_blank">jonath=
anbcoe@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"auto"><span class=3D""><div></div><div>Do you have an example of =
how this would allow one to re-write code in a <i>more maintainable way</i>=
?</div></span></div></blockquote><div><br>I just realised my example doesn'=
t fit your request for maintainability. From my experience with Haskell, I =
can say that it often makes code highly <i>reusable</i>, and there are a lo=
t of very flexible Haskell libraries that are only a few dozen lines long d=
ue to this. Once a handful of basic functions are in place, they can be use=
d and abused in an incredible variety of ways, and you don't need to think =
twice about doing so. A lot of this (not all, but a lot) is due to partial =
application and parameter flipping.<br><br>So in terms of <i>reusability,</=
i>&nbsp;maintainability can be improved.</div></div></div></div></div></blo=
ckquote><div><br></div><div><br></div>Interesting. As you say, the example =
you give can be done with lambdas; do you have an example where lambdas are=
 not a good fit?<br><blockquote type=3D"cite"><div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMtAos5KpLmvDAkxCNfBFJQQqKrTZ=
h7jfhv6vCKKFbtJw%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMt=
Aos5KpLmvDAkxCNfBFJQQqKrTZh7jfhv6vCKKFbtJw%40mail.gmail.com</a>.<br>
</div></blockquote></body></html>

<p></p>

-- <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 e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1A30B57E-40F5-452C-850C-55AF5F20F073%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1A30B57E-40F5-452C-850C-55AF5F20F073%=
40gmail.com</a>.<br />

--Apple-Mail-2421A84B-269F-43DD-BDB5-E116231E05E5--

.


Author: Nicolas Lesser <blitzrakete@gmail.com>
Date: Sat, 6 Jan 2018 13:57:10 -0800 (PST)
Raw View
------=_Part_121_296914613.1515275830924
Content-Type: multipart/alternative;
 boundary="----=_Part_122_549934375.1515275830924"

------=_Part_122_549934375.1515275830924
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable


>
> Do you have an example of how this would allow one to re-write code in a=
=20
> more maintainable way? I=E2=80=99m not familiar with Scala or the advanta=
ges that=20
> partial application can bring.
>

I imagine it is useful when you need to pass a function to an algorithm=20
which hasn't got the exact signature the algorithm needs. Basically, what=
=20
we would use std::bind or a lambda for currently:

    std::transform(Vec.begin(), Vec.end(), Vec.begin(), [](auto &&Var) {=20
return foo(10, Var); }); // now
    std::transform(Vec.begin(), Vec.end(), Vec.begin(), foo(10)); // after

It's a bit more maintainable just because it uses less characters I guess :=
)

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/d72691d1-58e5-474e-8b7d-07a29d73ddad%40isocpp.or=
g.

------=_Part_122_549934375.1515275830924
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"a=
uto"><div>Do you have an example of how this would allow one to re-write co=
de in a more maintainable way? I=E2=80=99m not familiar with Scala or the a=
dvantages that partial application can bring.<br></div></div></blockquote><=
div><br></div><div>I imagine it is useful when you need to pass a function =
to an algorithm which hasn&#39;t got the exact signature the algorithm need=
s. Basically, what we would use std::bind or a lambda for currently:</div><=
div><br></div><div>=C2=A0 =C2=A0 std::transform(Vec.begin(), Vec.end(), Vec=
..begin(), [](auto &amp;&amp;Var) { return foo(10, Var); }); // now</div><di=
v>=C2=A0 =C2=A0 std::transform(Vec.begin(), Vec.end(), Vec.begin(), foo(10)=
); // after</div><div><br></div><div>It&#39;s a bit more maintainable just =
because it uses less characters I guess :)</div></div>

<p></p>

-- <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 e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d72691d1-58e5-474e-8b7d-07a29d73ddad%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d72691d1-58e5-474e-8b7d-07a29d73ddad=
%40isocpp.org</a>.<br />

------=_Part_122_549934375.1515275830924--

------=_Part_121_296914613.1515275830924--

.