Add HtmlTag#withSelf, restore debounce example#155
Conversation
| label("Your email: "), | ||
| input { self => | ||
| input { (self: fs2.dom.HtmlInputElement[IO]) => // FIXME compiler bug | ||
| onInput --> (_.evalMap(_ => self.value.get).through(emailCh.sendAll)) |
There was a problem hiding this comment.
This is extremely annoying. Another workaround is to do:
input { self =>
Tuple1(onInput --> (_.evalMap(_ => self.value.get).through(emailCh.sendAll)))
}I'm going to try and minimize and report a compiler bug.
There was a problem hiding this comment.
2chilled
left a comment
There was a problem hiding this comment.
Seems like there's still work to do in regards to implementing overloads soundly, even in Scala 3. To this day, I've always avoided them without missing too much.
Yes, that is often good practice. Do you think we should do that here? We can add it as an alternative API e.g. input.withSelf { self =>
onInput --> (_.evalMap(_ => self.value.get).through(emailCh.sendAll))
}I think Laminar might call it |
|
I'd absolutely prefer that, yes. These types of bugs are super annoying, especially for non expert Scala users. In my experience it's best to even disable all nasty features that can be somehow disabled. At work, we use the strictest scalac 2 settings together with nearly all of https://www.wartremover.org/, and everyone is super happy with that. Furthermore, we still avoid Scala 3 there, because there are a bunch of strict flags not implemented (yet?). |
|
Ah and |
|
Great, I'll add that!
Good news, many new strict flags are arriving in Scala 3.3.0 :) |
HtmlTag#withSelf, restore debounce example
| build.toResource.flatTap(M.modify(modifier, _)) | ||
|
|
||
| def apply[M](mkModifier: E => M)(using M: Modifier[F, E, M]): Resource[F, E] = | ||
| def withSelf[M](mkModifier: E => M)(using M: Modifier[F, E, M]): Resource[F, E] = |
There was a problem hiding this comment.
Not to second guess 😅 maybe another option is fromSelf. But withSelf is good. I think 😅
| span( | ||
| label("Your email: "), | ||
| input { (self: fs2.dom.HtmlInputElement[IO]) => // FIXME compiler bug | ||
| input.withSelf { self => |
There was a problem hiding this comment.
Yeah, overloads are bad 😓
Yeah, seems like what I was trying to do here was an unsupported behavior according to scala/scala3#16737 (comment) 😅 |
Closes #132.