Quantcast

help simplifiing types

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

help simplifiing types

marcos rebelo
I have this method:

def withUploadStream[T, OS <: OutputStream](
        path: String,
        osCB: OutputStream => OS = identity[OutputStream] _
    )(
        cb: OS => T
    )(
        implicit ec: ExecutionContext
    ): Future[T] = {
   ...
}

I'm getting insane that I can't simplify the line:

        osCB: OutputStream => OS = identity[OutputStream] _

Seems like I need to repeat this OutputStream 2x. Is it possible to get read of it?

Best
Marcos

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help simplifiing types

Naftoli Gugenheim

What if you just write x => x?


On Sun, Apr 16, 2017 at 1:19 AM marcos rebelo <[hidden email]> wrote:
I have this method:

def withUploadStream[T, OS <: OutputStream](
        path: String,
        osCB: OutputStream => OS = identity[OutputStream] _
    )(
        cb: OS => T
    )(
        implicit ec: ExecutionContext
    ): Future[T] = {
   ...
}

I'm getting insane that I can't simplify the line:

        osCB: OutputStream => OS = identity[OutputStream] _

Seems like I need to repeat this OutputStream 2x. Is it possible to get read of it?

Best
Marcos

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

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help simplifiing types

marcos rebelo
if I do:

  def withUploadStream[T, OS <: OutputStream](
                                               path: String,
                                               osCB: OutputStream => OS = os => os
                                             )(
                                               cb: OS => T
                                             )(
                                               implicit ec: ExecutionContext
                                             ): Future[T] = {

I get:

missing parameter type
[error]                                                osCB: OutputStream => OS = os => os
[error]                                                                           ^

and once again I need:

osCB: OutputStream => OS = {os: OutputStream => os}

Is there a better way?

Best
Marcos


On Sun, Apr 16, 2017 at 8:15 AM, Naftoli Gugenheim <[hidden email]> wrote:

What if you just write x => x?


On Sun, Apr 16, 2017 at 1:19 AM marcos rebelo <[hidden email]> wrote:
I have this method:

def withUploadStream[T, OS <: OutputStream](
        path: String,
        osCB: OutputStream => OS = identity[OutputStream] _
    )(
        cb: OS => T
    )(
        implicit ec: ExecutionContext
    ): Future[T] = {
   ...
}

I'm getting insane that I can't simplify the line:

        osCB: OutputStream => OS = identity[OutputStream] _

Seems like I need to repeat this OutputStream 2x. Is it possible to get read of it?

Best
Marcos

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

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help simplifiing types

Viktor Klang
OutputStream is more general than OS, you can't prove all OutputStreams are OSs (identity). (OS => OutputStream would work tho)

--
Cheers,

On Apr 16, 2017 14:39, "marcos rebelo" <[hidden email]> wrote:
if I do:


  def withUploadStream[T, OS <: OutputStream](
                                               path: String,
                                               osCB: OutputStream => OS = os => os

                                             )(
                                               cb: OS => T
                                             )(
                                               implicit ec: ExecutionContext
                                             ): Future[T] = {

I get:

missing parameter type
[error]                                                osCB: OutputStream => OS = os => os
[error]                                                                           ^

and once again I need:

osCB: OutputStream => OS = {os: OutputStream => os}

Is there a better way?

Best
Marcos


On Sun, Apr 16, 2017 at 8:15 AM, Naftoli Gugenheim <[hidden email]> wrote:

What if you just write x => x?


On Sun, Apr 16, 2017 at 1:19 AM marcos rebelo <[hidden email]> wrote:
I have this method:

def withUploadStream[T, OS <: OutputStream](
        path: String,
        osCB: OutputStream => OS = identity[OutputStream] _
    )(
        cb: OS => T
    )(
        implicit ec: ExecutionContext
    ): Future[T] = {
   ...
}

I'm getting insane that I can't simplify the line:

        osCB: OutputStream => OS = identity[OutputStream] _

Seems like I need to repeat this OutputStream 2x. Is it possible to get read of it?

Best
Marcos

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

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

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