Skip to content
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

New type derivation not working on list types #1569

Open
kuzkdmy opened this issue Oct 10, 2021 · 1 comment
Open

New type derivation not working on list types #1569

kuzkdmy opened this issue Oct 10, 2021 · 1 comment
Assignees

Comments

@kuzkdmy
Copy link

kuzkdmy commented Oct 10, 2021

Read not derived, next code results in such error

Cannot find or construct a Read instance for type: com.test.Main.DataWrapper2
But derivation works with simple Read[NewTypeWrapper]

package com.test

import doobie._
import doobie.postgres.implicits._
import io.estatico.newtype.macros.newtype

object Main extends App {
  @newtype case class NewTypeWrapper(value: Int)
  object NewTypeWrapper {
    implicit val read: Read[NewTypeWrapper] = Read[Int].map(NewTypeWrapper(_))
  }
  case class DataWrapper(one: NewTypeWrapper)
  case class DataWrapper1(list: List[Int])
  case class DataWrapper2(list: List[NewTypeWrapper])

  val t = NewTypeWrapper(1)
  println(Read[NewTypeWrapper])
  println(Read[DataWrapper])
  println(Read[DataWrapper1])
  println(Read[DataWrapper2])
}
@kuzkdmy
Copy link
Author

kuzkdmy commented Oct 12, 2021

May be solution described here #691

@jatcwang jatcwang self-assigned this Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants