I have the below conf file:
connection.port = 8080
connection.interface = "127.0.0.1"
I am trying to use refined and refined-pureconfig when reading this file. I have the below class:
import com.api.models.{Config, Connection}
import com.typesafe.config.ConfigFactory
import pureconfig.error.ConfigReaderFailures
import pureconfig.loadConfig
object Configuration {
val config = ConfigFactory.load()
val stuff: Either[ConfigReaderFailures, Connection] = loadConfig[Connection](config)
stuff match {
case Left(left) => println(left)
case Right(right) => println(right)
}
}
This is reading the below case class:
case class Connection(port: Int, interface: String)
However when I try to compile this, I get the following error:
Error:(19, 79) could not find implicit value for parameter reader: pureconfig.Derivation[pureconfig.ConfigReader[com.api.models.Connection]]
val stuff: Either[ConfigReaderFailures, Connection] = loadConfig[Connection](config)
I'm really not sure how to create such an implicit?
Most likely you're missing an import probably this one:
import pureconfig.generic.auto._
see https://pureconfig.github.io/docs/
If you're interested in what's happening here you can look into "typeclass derivation"
EDIT: Note that right now this has nothing to do with refined types as your code snipped is not using them.