Skip to content

New type derivation not working on list types #1569

Open
@kuzkdmy

Description

@kuzkdmy

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])
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions