Rewrite twiddle syntax on Scala 3 as extension methods
This was partially done in #9 but I was unable to get all examples compiling. The goal is to remove these implicit conversions: https://github.com/typelevel/twiddles/blob/7a26b389b9a8e638b06a1a8041f727905975aee0/core/shared/src/main/scala-3/org/typelevel/twiddles/Twiddles.scala#L38-L41 and the associated AnyVals.
See #11 for a potential starting point.
Note part of #9 had to be rolled back due to #19
I recently ran into the same problem as in #19 but needed a solution that works with extension methods. It's not pretty, but it works, so I'm just leaving this here as trivia:
Not working, breaks type inference (see #19):
extension [A](self: Self[A])
def imap[B](f: A => B)(g: B => A): Self[B]
def to[B](using convert: Convert[A, B]): Self[B] = imap(convert.to)(convert.from)
Surprisingly working, but the additional parentheses were a deal-breaker for me:
extension [A](self: Self[A])
def imap[B](f: A => B)(g: B => A): Self[B]
def to[B]()(using convert: Convert[A, B]): Self[B] = imap(convert.to)(convert.from)
Working drop-in replacement:
extension [A](self: Self[A])
def imap[B](f: A => B)(g: B => A): Self[B]
inline def to[B]: Self[B] =
val convert = summonInline[Convert[A, B]]
imap(convert.to)(convert.from)