Re: Filter on future doesn't make sense

Avi Levi <[email protected]> Fri, 1 Jul 2016 10:20:38 +0300
Newsgroups gmane.comp.lang.scala
Message-ID <CAP0Sp2m2dZbc6Bv3DoeHonvCN5Mx-WSJtPTgOFNdfHJ5AKstKw@mail.gmail.com>
Thanks Victor,
Of course it can be implemented as you suggested. But still I can argue
that the current implementation is not "really filtering" the results as
one might expect and less expressive if it might or not return the value
than Option is more expressive, don't you agree?
On Jul 1, 2016 10:06 AM, "Viktor Klang" <[email protected]> wrote:

> Hi Avi,
>
> Use Fututre[Option[Int]] if you want to deal with Some/None as a result of
> filter ( f.map(_.filter(p) ) (alt. see monad transformers)
>
> --
> Cheers,
> √
> On Jul 1, 2016 8: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 ?) .
> 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 a topic in the
> Google Groups "scala-language" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/scala-language/wpGOB8f7qmY/unsubscribe.
> To unsubscribe from this group and all its topics, 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.