-
Notifications
You must be signed in to change notification settings - Fork 65
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
Error handling and abstract effects #313
Comments
It might be an issue with type inference because if I widen the types manually to the correct one it compiles: class Y[F[_]: Sync]() extends CirceEntityEncoder with SwaggerSyntax[F] {
type YT =
Result[F,
Nothing,
Nothing,
Nothing,
Nothing,
String,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
String,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing,
Nothing]
type YTT = F[YT]
def swaggerRoutesF(api: Api[F]) =
new RhoRoutes[F] {
val yo: YTT = {
api.isOk.flatMap {
case true => Ok("ok").widen[YT]
case false => Forbidden("not allowed").widen[YT]
}
}
"Example api endpoint" **
GET / "example" |>> yo
}
} |
I've played around a bit more with the explicitly typed example (
The important part is the suggestion that I should make the argument to the effect type covariant. That fixed the example and my original code as well so it's not a bug, I'll close this issue. |
Follow up notes: |
I'm trying to use an abstract effect type when defining my routes but I run into errors due to some missing implicits(if I understand it correctly). Here's the code:
The error is:
It looks like it can't merge the two
Result
type, but when I useIO
I get something like this:Result[F, ...bunch of Nothing..., String, ..more Nothing..., String, ... more Nothing ...]
which includes both possibilities(the generated docs also look good for the IO version, I can see the 2 different kind of response types).I also get these two errors:
Which leads me to believe that I'm missing some implicit, but couldn't figure out what exactly. Here's the full source of the poc: https://gist.github.com/erdeszt/fc2b461e9b0ae70c6dd9fd7e432392e4
The text was updated successfully, but these errors were encountered: