Iltotore / iron

Strong type constraints for Scala
https://iltotore.github.io/iron/docs/
Apache License 2.0
457 stars 43 forks source link

Add support for skunk #192

Closed jnicoulaud-ledger closed 10 months ago

jnicoulaud-ledger commented 11 months ago

Adds support for Skunk.

jnicoulaud-ledger commented 11 months ago

Not sure this is the good way of doing things, if I try the case class example with implicit conversions:

// defining a codec for a refined case class
final case class User(name: Username, age: Int :| Positive)
given Codec[User] = (varchar *: int4).to[User]

Compilation fails with a compiler crash:

java.lang.AssertionError: assertion failed while typechecking /home/jnicoulaud/work/foss/iron/skunk/test/src/io/github/iltotore/iron/SkunkExample.scala
Iltotore commented 11 months ago

What is the full error thrown by the compiler?

jnicoulaud-ledger commented 11 months ago

https://gist.github.com/jnicoulaud-ledger/4de31bd71a8a0562d1fba1c5ab75eaf8

Iltotore commented 11 months ago

The test module, including this part:

// defining a codec for a refined case class
final case class User(name: Username, age: Int :| Positive)
given Codec[User] = (varchar.refined[Not[Blank]] *: int4.refined[Positive]).to[User]

seems to compile and work as expected. Am I missing something?

EDIT: Nevermind, I found the difference.