Re: Filter on future doesn't make sense

Naftoli Gugenheim <[email protected]> Sun, 10 Jul 2016 05:19:10 +0000
Newsgroups gmane.comp.lang.scala
Message-ID <CANpg8PBHU1NFmVN_=2qhqSj26fvZORuN1-cz__Dtu7=Vqw7Nng@mail.gmail.com>
--001a114669ac837e0f0537412ddb
Content-Type: text/plain; charset=UTF-8

On Fri, Jul 1, 2016, 2:53 AM Avi Levi <[email protected]> wrote:

> I was trying to figure out what should I accept when filtering over a
> future .
> the current implementation yields either a T or an exception which kind of
> breaks referential transparency (doesn't it ?) .
>

How would it break referential transparency? It's just a value that happens
to extend Throwable. (Actually throwing an exception might break RT, but
that's not happening.)

Isn't there the same question about Try#filter?



on the other hand what can I expect given this expression
>
> *def foo(i:Int):Future[Int]*
>
> the type result of
>
> *foo(1).filter(_ % 2 == 0)*
>
>
> I.M.H.O I would expect it to yield Option[T]  which makes more sense to
> express that we might get a value that pass the filter or not . is that
> make sense ?
>
> Cheers
> Avi
>
> --
> 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.
>

-- 
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.

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

<br><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Fri, Jul 1, 2016, 2:=
53 AM Avi Levi &lt;<a href=3D"mailto:[email protected]">[email protected]</a>=
&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 =
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I was =
trying to figure out what should I accept when filtering over a future .<di=
v>the current implementation yields either a T or an exception which kind o=
f breaks referential transparency (doesn&#39;t it ?) .</div></div></blockqu=
ote></div><div><br></div><div>How would it break referential transparency? =
It&#39;s just a value that happens to extend Throwable. (Actually throwing =
an exception might break RT, but that&#39;s not happening.)</div><div><br><=
/div><div>Isn&#39;t there the same question about Try#filter?</div><div><br=
></div><div><br></div><div><br></div><div class=3D"gmail_quote"><blockquote=
 class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr"><div>on the other hand what can I expe=
ct given this expression=C2=A0</div><div>







<p><span><i>def foo(i:Int):Future[Int]</i></span></p><p><span>the type resu=
lt of=C2=A0</span></p><p><i>foo(1).filter(_ % 2 =3D=3D 0)</i></p>







<p><span><br></span></p></div><div>I.M.H.O I would expect it to yield Optio=
n[T] =C2=A0which makes more sense to express that we might get a value that=
 pass the filter or not . is that make sense ?</div><div><br></div><div>Che=
ers</div><div>Avi=C2=A0</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">[email protected]</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" targ=
et=3D"_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></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 />

--001a114669ac837e0f0537412ddb--