Well, I've suggested it: https://github.com/scala/scala/pull/5137

On Wednesday, April 27, 2016 at 4:41:07 PM UTC+2, Bruno Bieth wrote:
>
> I agree with Roland that having a Future[Unit] may lead to subtle bugs due 
> to the value discarding mechanism. My favorite is mixing map and flatMap by 
> mistake:
>
> // this compiles just fine: map[T] is infered to be map[Unit], then Future 
> { println("two"); Done } which is of type Future[Done] is discarded to 
> satisfy map[Unit]
> def compute: Future[Unit] = Future[Done] { println("one"); Done }.map( _ 
> => Future { println("two"); Done } )
>
> On the other hand:
>
> // won't compile!
> def compute: Future[Done] = Future[Done] { println("one"); Done }.map( _ 
> => Future { println("two"); Done } )
>
> Now, this could be a good reason for bringing this into the scala library?
>
> Bruno
>
>
> On Wednesday, February 24, 2016 at 5:12:24 PM UTC+1, rkuhn wrote:
>>
>> There is one other use that these types can be put to: Scala’s habit of 
>> conjuring a Unit out of thin air where needed can make it non-obvious where 
>> all the exit points of a method are. Declaring a different return type 
>> means that all such points need to be marked out explicitly. But outside 
>> the method this is not very useful (and this was also not the reason for 
>> the introduction of these types). As Patrik and Konrad note these are 
>> intended to be used a type parameters.
>>
>> Regards,
>>
>> Roland
>>
>> 24 feb 2016 kl. 15:36 skrev Konrad Malawski <kt...@lightbend.com>:
>>
>> Yeah, agree with Patrik here.
>> It's mostly for `Future[Done]` and situations like that, void/Unit is 
>> still fine in normal return values.
>>
>> -- 
>> Cheers,
>> Konrad 'ktoso’ Malawski
>> <http://akka.io/>Akka <http://akka.io/> @ Lightbend 
>> <http://typesafe.com/>
>> <http://lightbend.com/>
>>
>> On 24 February 2016 at 13:35:02, Patrik Nordwall (patrik....@gmail.com) 
>> wrote:
>>
>>
>>
>> On Wed, Feb 24, 2016 at 1:23 PM, rklaehn <rkl...@gmail.com> wrote:
>>
>>> Hi Konrad,
>>>
>>> So, if it wasn't for backward compatibility, the return type of tell 
>>> would be akka.NotUsed, to signal that successful return does not tell you 
>>> anything about successful processing of the message (akka.Done would 
>>> certainly be wrong)?
>>>
>>
>> That would be to take it one step to far, I would say. Ordinary methods 
>> should still be declared with void (java) or Unit (scala) return types. 
>> Done and NotUsed are mostly interesting when the return value is not 
>> immediate, such as in a CompletionStage (java), Future (scala), or stream 
>> materialized value.
>>  
>>
>> Cheers,
>>
>> Rüdiger
>>
>> On Wednesday, February 24, 2016 at 11:43:33 AM UTC+1, Konrad Malawski 
>> wrote:
>> Hey Rüdiger,
>> yeah those can definitely be used in all kinds of APIs.
>> The reason we have them mostly in Streams for now is because we could not 
>> break compatibility in akka-actor for example.
>>
>> The types are intended to be simply more informative than plain `Unit`, 
>> so wherever that's needed feel free to use them :-)
>>
>> -- 
>> Cheers,
>> Konrad 'ktoso’ Malawski
>> <http://akka.io/>Akka <http://akka.io/> @ Lightbend 
>> <http://typesafe.com/>
>> <http://lightbend.com/>
>>
>> On 24 February 2016 at 11:41:57, rklaehn (rkl...@gmail.com) wrote:
>>
>> Hi all,
>>
>> given the prominent position of akka.Done and akka.NotUsed: are these 
>> only meant to be used within akka streams, or also elsewhere?
>>
>> I am currently trying to introduce futures into a codebase with a lot of 
>> blocking, and it sure would be helpful to distinguish between methods 
>> returning Unit where successful return signals successful completion, and 
>> methods where successful return means nothing (e.g. because it is sending 
>> to some actor inside the method using !).
>>
>> Would this be a valid use case for using Done and NotUsed?
>>
>> Cheers,
>>
>> Rüdiger
>> --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com.
>> To post to this group, send email to akka...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com.
>> To post to this group, send email to akka...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>>
>> Patrik Nordwall
>> Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
>> Twitter: @patriknw
>>
>> [image: Lightbend] <http://www.lightbend.com/>
>> --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com.
>> To post to this group, send email to akka...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> -- 
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com.
>> To post to this group, send email to akka...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> *Dr. Roland Kuhn*
>> *Akka Tech Lead*
>> Typesafe <http://typesafe.com/> – Reactive apps on the JVM.
>> twitter: @rolandkuhn
>> <http://twitter.com/#!/rolandkuhn>
>>
>>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to