Skip to content

Instantly share code, notes, and snippets.

@yasuabe
Created April 18, 2019 13:33
Show Gist options
  • Save yasuabe/f63b4306e231157855132465f7115107 to your computer and use it in GitHub Desktop.
Save yasuabe/f63b4306e231157855132465f7115107 to your computer and use it in GitHub Desktop.
squants exercise with pureconfig
package exercise.squants.with_pureconfig
import pureconfig.ConfigReader.Result
import squants.motion.Pressure
import pureconfig.module.squants._
import pureconfig.generic.auto._
import squants.Mass
import squants.thermal._
import squants.space._
case class EarthConfig(
meanRadius: Length, // 平均半径
volume: Volume, // 体積
mass: Mass, // 質量
atmosphericPressure: Pressure, // 大気圧
averageTemperature: Temperature // 平均気温
)
object Main {
def main(args: Array[String]): Unit = {
val config: Result[EarthConfig] = pureconfig.loadConfig[EarthConfig]
println(config.fold(_.toList.map(_.description).mkString("\n"), _.toString))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment