Kanaka-io / play-monadic-actions

A simple scala DSL to allow clean and monadic style for Play! Actions
Other
128 stars 29 forks source link

Compilation failures with v2.1 to v2.2 upgrade #44

Open marko-asplund opened 4 years ago

marko-asplund commented 4 years ago

I'm experiencing compilation problems when upgrading from v2.1.0 to v2.2.0. These seem to be related to the addition of fBooleanToStepOps implicit conversion. Could you please provide some context on why the function was added?

I'm getting the following compilation error:

[error] Foo.scala:1:1: overloaded method ?| with alternatives:
[error]   (failureThunk: => play.api.mvc.Result)io.kanaka.monadic.dsl.Step[Unit] <and>
[error]   (failureHandler: Unit => play.api.mvc.Result)io.kanaka.monadic.dsl.Step[Unit]
[error]  cannot be applied to (Throwable => play.api.mvc.Result)
[error]       result   <- myOp()   ?| errorHandler("Failed do smth")
def myOp(): Future[Boolean] = ???
def errorHandler(msg: String): Throwable => Result = ???

I'm using the following import:

import io.kanaka.monadic.dsl.

With version v2.2.0 both futureToStepOps and fBooleanToStepOps can provide the required conversion whereas with v2.1.0 there's only futureToStepOps.

Use of futureToStepOps conversion results in StepOps[A, Throwable] and fBooleanToStepOps in StepOps[Unit, Unit], causing the compilation failure.

The code compiles with v2.2.0 if I e.g. shadow fBooleanToStepOps as follows:

import io.kanaka.monadic.dsl.{fBooleanToStepOps => _, _}
vil1 commented 4 years ago

can you please provide a full code example that was compiling with 2.1 and breaks with 2.2?

vil1 commented 3 years ago

Can you please test again with 2.2.1?

marko-asplund commented 3 years ago

Still getting the same error with the new version:

[error] Foo.scala:1:1: overloaded method value ?| with alternatives:
[error]   (failureThunk: => play.api.mvc.Result)io.kanaka.monadic.dsl.Step[Unit] <and>
[error]   (failureHandler: Unit => play.api.mvc.Result)io.kanaka.monadic.dsl.Step[Unit]
[error]  cannot be applied to (Throwable => play.api.mvc.Result)
[error]       result   <- myOp()   ?| errorHandler("Failed do smth")
[error]                            ^