Re: Option flatten does not use an implicit conversion

Naftoli Gugenheim <[email protected]> Fri, 04 Mar 2016 15:18:45 +0000
Newsgroups gmane.comp.lang.scala
Message-ID <CANpg8PBUxD3GSF1SLk26A2Q8Dy2w+K=t5JBAf4tbHFbT99zrBQ@mail.gmail.com>
I think he means it should use the equivalent of view bounds, rather than
requiring evidence that it's an actual subtype. def flatten[B](implicit
view: A => Option[B]): ...

The answer is the same issue with all implicit conversions: They make
behavior more surprising and less type-constrained.


On Fri, Mar 4, 2016 at 10:01 AM Oliver Ruebenacker <[email protected]> wrote:

>
>      Hello,
>
>   How would it work with an implicit conversion?
>
>      Best, Oliver
>
> On Fri, Mar 4, 2016 at 5:33 AM, Bruno Bieth <[email protected]> wrote:
>
>> I was surprised that Some(Success(1)).flatten does not compile?
>> What is the rationale behind this:
>>
>> def flatten[B](implicit ev: A <:< Option[B]): Option[B] = if (isEmpty)
>> None else ev(this.get)
>>
>> Why not having an implicit conversion: (implicit conv: A => Option[B])?
>>
>> Bruno
>>
>> --
>> 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.
>>
>
>
>
> --
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal
> <http://www.type2diabetesgenetics.org/>, Broad Institute
> <http://www.broadinstitute.org/>
>
> --
> 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.