typelevel / skunk

A data access library for Scala + Postgres.
https://typelevel.org/skunk/
MIT License
1.59k stars 163 forks source link

Type inference for type argument in `to[A]` no longer working #1034

Closed taig closed 10 months ago

taig commented 10 months ago

Until 1.1.0-M2, the following code would compile just fine:

import skunk.Codec
import skunk.codec.all.*

case class Foo(x: Int, y: String)

val codec: Codec[Foo] = (int4 *: text).to

https://scastie.scala-lang.org/OaeJYGVVRMCGwRoeDWezCw

However, in 1.1.0-M2 and M3, it stopped working:

https://scastie.scala-lang.org/3CAm3UaGTCCdInd4VplVqg

One workaround is to specify the type argument explicitly:

val codec: Codec[Foo] = (int4 *: text).to[Foo]

https://scastie.scala-lang.org/AltZ0R9yRRWk8odKKchXtQ

Or to import twiddles syntax explicitly:

import org.typelevel.twiddles.syntax.*

https://scastie.scala-lang.org/8RmxWx2cQBWtWA97buW61g

taig commented 10 months ago

Thanks for the fix 👍 (1.0.0-M4)