-
Notifications
You must be signed in to change notification settings - Fork 41
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
Use Nothing
for no Result
#52
Conversation
This is the best minimization I've found so far: class LambdaSuite {
def lambda[F[_]]: Resource[F, Lambda[F, Unit, Nothing]] = ???
def middleware[F[_], Event, Result, Env](lambda: Resource[F, Lambda[Kleisli[F, Env, *], Event, Result]]): Resource[F, Lambda[F, Event, Result]] = ???
implicit val nothing: Encoder[Nothing] = _ => ???
class NothingLambda extends IOLambda[Unit, Nothing] {
def handler =
middleware(lambda[Kleisli[IO, Unit, *]].mapK(Kleisli.applyK(())))
}
}
It doesn't matter if the value passed to
|
Co-authored-by: Brian Holt <bholt@dwolla.com>
@bpholt thanks! That's an excellent minimization, exactly what I was looking for :) Unfortunately, placing the |
Darn, 2.12 seems to be lacking. Dare I say ... we drop it? 😆 |
Dropping 2.12 seems reasonable to me. I don't think the common reasons why people are stuck on 2.12 would apply in this context. |
Yeah, apparently we are "future-forward" or something 😆 If it becomes an issue we can probably bring back 2.12 very easily anyway. Those users would just need to explicitly import this implicit and we'd need to make this test 2.13/3.x-only. FTR if sbt supported this config out-of-the-box that's exactly what I would have done. |
Ummm ... Scala 3 is broken too? Seems like a compiler bug 🤔
Update: tracking in scala/scala3#13981. |
tl;dr but I like the idea of |
@kubukoz you're not stuck on Scala 2.12 are you? The tl;dr here is mostly about implicit scope for |
I'm on 2.13, |
Try |
man, I can only have one experimental branch in my dependencies at a time 😂 |
* userland code returns `Some`. | ||
*/ | ||
@nowarn("msg=dead code following this construct") | ||
implicit val nothingEncoder: Encoder[INothing] = (_: INothing) => ??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not 100% sure but can't this just return its argument? (a: INothing) => a
. INothing <: Nothing
and Nothing <: Json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, this does work :)
Actually you should have this in your branch, it's split off :) |
we're reaching levels of stable that shouldn't be possible! |
def middleware[F[_], Event, Result](lambda: Lambda[Kleisli[F, Unit, *], Event, Result]) | ||
: Resource[F, Lambda[F, Event, Result]] = ??? | ||
|
||
class NothingLambda extends IOLambda[Unit, INothing] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I'm not mistaken this should even work with just Nothing
, at least on 2.13
This seems mergeable as well... |
Yep, I'm just dealing with the conflicts rn :) |
Based on #51.
@bpholt Before cherry-picking 00eb18f I wanted to try and write a test in 06c9eee that demonstrates the compiler issue with
Nothing
. I tried replicating your example from #45 (comment) but didn't have much luck. When you have chance would you mind poking at this? Thanks :)