Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ResponseAs[T, S] covariant on T #408

Closed
darl opened this issue Jan 24, 2020 · 3 comments
Closed

Make ResponseAs[T, S] covariant on T #408

darl opened this issue Jan 24, 2020 · 3 comments

Comments

@darl
Copy link

darl commented Jan 24, 2020

I wrote following combinator:

def fromStatus[T, S](mapping: (Int, ResponseAs[T, S])*): ResponseAs[T, S] = {
  fromMetadata { meta =>
    val statusCode = meta.code.code
    mapping.toMap.getOrElse(statusCode, sys.error(s"No parser for status $statusCode"))
  }
}

And want to use it in following way:

fromStatus(
  200 -> protoBody[MyModel].map(Right(_)),
  404 -> ignore.map(_ => Left(NotFound()))
)

But now i forced to explicitly provide all types explicitly:

fromStatus(
  200 -> protoBody[MyModel].map(Right(_): Either[NotFound, MyModel]),
  404 -> ignore.map(_ => Left(NotFound()): Either[NotFound, MyModel])
)
@adamw
Copy link
Member

adamw commented Jan 24, 2020

Why not! Can you maybe try modifying the source (creating a PR :) ) and checking if this causes any problems?

@darl
Copy link
Author

darl commented Jan 24, 2020

Yes. I will try it!

adamw added a commit that referenced this issue Feb 18, 2020
…e of body in backends when needed to make the compiler happy.
@adamw
Copy link
Member

adamw commented Feb 18, 2020

Fixed in 2.0.0-RC11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants