Re: Any should have map for readability

Viktor Klang <[email protected]> Fri, 5 Aug 2016 11:27:41 +0200
Newsgroups gmane.comp.lang.scala
Message-ID <CANPzfU8qfAkG2DJCYugGomPheufrHNK7+SLr8YNP=Rpua0KX4g@mail.gmail.com>
--001a113d8094ad3c0f05394fad85
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Lift your Any into the Identity monad?

--=20
Cheers,
=E2=88=9A

On Aug 5, 2016 11:11 AM, "Carl Emmoth" <[email protected]> wrote:

> Warning: Amateur suggestion!
> Example
> So there's a lot of code examples in this form:
>
> val server =3D Http.serve(":8080", service)Await.ready(server)
>
>
>    1. Instancing
>    2. Calling method with instance
>
> It might look concrete but the instancing looks unnecessary.
> Suggestion
> Since we usually read from left to right, we would also like to read the
> code in chronological order like when using map
>
> Http.serve(":8080", service) map Await.ready
>
>
> But since Any doesn't have map, a suggested syntax would be
>
> Http.serve(":8080", service) (Await.ready)
>
> Similartiy with Collection
> This is similar to collections which have map. Here's examples with map
>
> 1 to 3 map println
>
> 1 to 3 map (_ + 10) map println
>
>
> Any without map could be like this then
>
> 10 (println)
>
> 10 (_ + 10) (println)
>
> --
> You received this message because you are subscribed to the Google Groups
> "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

--=20
You received this message because you are subscribed to the Google Groups "=
scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
For more options, visit https://groups.google.com/d/optout.

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

<p dir=3D"ltr">Lift your Any into the Identity monad?</p>
<p dir=3D"ltr">-- <br>
Cheers,<br>
=E2=88=9A</p>
<div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Aug 5, 2016 11=
:11 AM, &quot;Carl Emmoth&quot; &lt;<a href=3D"mailto:[email protected]=
">[email protected]</a>&gt; wrote:<br type=3D"attribution"><blockquote =
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid=
;padding-left:1ex"><div dir=3D"ltr">Warning: Amateur suggestion!<div><font =
size=3D"4">Example</font></div><div>So there&#39;s a lot of code examples i=
n this form:</div><div><pre style=3D"overflow-x:auto;overflow-y:hidden;font=
-family:Consolas,Menlo,&quot;Deja Vu Sans Mono&quot;,&quot;Bitstream Vera S=
ans Mono&quot;,monospace;font-size:0.9em;padding:10px;line-height:1.3em;bor=
der-radius:5px;border:1px solid rgb(238,238,238);color:rgb(62,67,73);backgr=
ound:rgb(253,253,253)"><span style=3D"color:rgb(0,68,97);font-weight:bold">=
val</span> <span style=3D"color:rgb(0,0,0)">server</span> <span style=3D"co=
lor:rgb(0,68,97);font-weight:bold">=3D</span> <span style=3D"color:rgb(0,0,=
0)">Http</span><span style=3D"color:rgb(88,40,0)">.</span><span style=3D"co=
lor:rgb(0,0,0)">serve</span><span style=3D"color:rgb(88,40,0)">(</span><spa=
n style=3D"color:rgb(78,154,6)">&quot;:8080&quot;</span><span style=3D"colo=
r:rgb(88,40,0)">,</span> <span style=3D"color:rgb(0,0,0)">service</span><sp=
an style=3D"color:rgb(88,40,0)">)</span>
<span style=3D"color:rgb(0,0,0)">Await</span><span style=3D"color:rgb(88,40=
,0)">.</span><span style=3D"color:rgb(0,0,0)">ready</span><span style=3D"co=
lor:rgb(88,40,0)">(</span><span style=3D"color:rgb(0,0,0)">server</span><sp=
an style=3D"color:rgb(88,40,0)">)</span></pre></div><div><ol><li><span styl=
e=3D"line-height:normal">Instancing=C2=A0</span></li><li><span style=3D"lin=
e-height:normal">Calling method with instance</span></li></ol><div>It might=
 look concrete but the instancing looks unnecessary.</div></div><div><font =
size=3D"4">Suggestion</font></div><div>Since we usually read from left to r=
ight, we would also like to read the code in chronological order like when =
using map</div><div><pre style=3D"padding:10px;border:1px solid rgb(238,238=
,238);overflow-x:auto;overflow-y:hidden;font-family:Consolas,Menlo,&quot;De=
ja Vu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,monospace;font-s=
ize:0.9em;line-height:1.3em;border-radius:5px;color:rgb(62,67,73);backgroun=
d:rgb(253,253,253)"><span style=3D"color:rgb(0,0,0)">Http</span><span style=
=3D"color:rgb(88,40,0)">.</span><span style=3D"color:rgb(0,0,0)">serve</spa=
n><span style=3D"color:rgb(88,40,0)">(</span><span style=3D"color:rgb(78,15=
4,6)">&quot;:8080&quot;</span><span style=3D"color:rgb(88,40,0)">,</span> <=
span style=3D"color:rgb(0,0,0)">service</span><span style=3D"color:rgb(88,4=
0,0)">) map Await.ready</span></pre></div><div><br></div><div>But since Any=
 doesn&#39;t have map, a suggested syntax would be</div><div><pre style=3D"=
padding:10px;border:1px solid rgb(238,238,238);overflow-x:auto;overflow-y:h=
idden;font-family:Consolas,Menlo,&quot;Deja Vu Sans Mono&quot;,&quot;Bitstr=
eam Vera Sans Mono&quot;,monospace;font-size:0.9em;line-height:1.3em;border=
-radius:5px;color:rgb(62,67,73);background:rgb(253,253,253)"><span style=3D=
"color:rgb(0,0,0)">Http</span><span style=3D"color:rgb(88,40,0)">.</span><s=
pan style=3D"color:rgb(0,0,0)">serve</span><span style=3D"color:rgb(88,40,0=
)">(</span><span style=3D"color:rgb(78,154,6)">&quot;:8080&quot;</span><spa=
n style=3D"color:rgb(88,40,0)">,</span> <span style=3D"color:rgb(0,0,0)">se=
rvice</span><span style=3D"color:rgb(88,40,0)">) (Await.ready)</span></pre>=
</div><div><font size=3D"4">Similartiy with Collection</font></div><div>Thi=
s is similar to collections which have map. Here&#39;s examples with map</d=
iv><div><pre style=3D"padding:10px;border:1px solid rgb(238,238,238);overfl=
ow-x:auto;overflow-y:hidden;font-family:Consolas,Menlo,&quot;Deja Vu Sans M=
ono&quot;,&quot;Bitstream Vera Sans Mono&quot;,monospace;font-size:0.9em;li=
ne-height:1.3em;border-radius:5px;background:rgb(253,253,253)"><font color=
=3D"#000000">1 to 3 map println</font></pre><pre style=3D"padding:10px;bord=
er:1px solid rgb(238,238,238);overflow-x:auto;overflow-y:hidden;border-radi=
us:5px;background:rgb(253,253,253)"><font color=3D"#000000"><font face=3D"C=
onsolas, Menlo, Deja Vu Sans Mono, Bitstream Vera Sans Mono, monospace"><sp=
an style=3D"font-size:11.7px;line-height:15.21px">1 to 3 map (_ + 10) map p=
rintln</span><span style=3D"font-size:0.9em;line-height:1.3em"><br></span><=
/font></font></pre></div><div><br></div><div>Any without map could be like =
this then</div><div><pre style=3D"padding:10px;border:1px solid rgb(238,238=
,238);overflow-x:auto;overflow-y:hidden;font-family:Consolas,Menlo,&quot;De=
ja Vu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,monospace;font-s=
ize:0.9em;line-height:1.3em;border-radius:5px;background:rgb(253,253,253)">=
<font color=3D"#000000">10 (println)</font></pre><pre style=3D"padding:10px=
;border:1px solid rgb(238,238,238);overflow-x:auto;overflow-y:hidden;font-f=
amily:Consolas,Menlo,&quot;Deja Vu Sans Mono&quot;,&quot;Bitstream Vera San=
s Mono&quot;,monospace;font-size:0.9em;line-height:1.3em;border-radius:5px;=
background:rgb(253,253,253)"><font color=3D"#000000">10 (_ + 10) (println)<=
/font></pre></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;scala-language&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]" targ=
et=3D"_blank">scala-language+unsubscribe@<wbr>googlegroups.com</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" targ=
et=3D"_blank">https://groups.google.com/d/<wbr>optout</a>.<br>
</blockquote></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;scala-language&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">scal=
[email protected]</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />

--001a113d8094ad3c0f05394fad85--