Skip to content

Commit

Permalink
rename derivation traits
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz-bielski committed Mar 24, 2024
1 parent 3fe7c14 commit 8e5c5b9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions build.sbt
Expand Up @@ -94,9 +94,7 @@ lazy val commonSettings = Seq(
Developer("derekmorr", "Derek Morr", "morr.derek@gmail.com", url("https://github.com/derekmorr"))
),

// scalaVersion := scala212,
// TODO: temporary, for development only
scalaVersion := scala3,
scalaVersion := scala212,

resolvers ++= Resolver.sonatypeOssRepos("releases"),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
Expand Down
Expand Up @@ -4,13 +4,15 @@ package derivation

import scala.deriving.Mirror

trait ConfigReaderDerivation extends CoproductConfigReaderDerivation, ProductConfigReaderDerivation:
trait HintsAwareConfigReaderDerivation
extends HintsAwareCoproductConfigReaderDerivation,
HintsAwareProductConfigReaderDerivation:
inline def deriveReader[A](using m: Mirror.Of[A], ph: ProductHint[A], cph: CoproductHint[A]): ConfigReader[A] =
inline m match
case given Mirror.ProductOf[A] => deriveProductReader[A]
case given Mirror.SumOf[A] => deriveSumReader[A]

object ConfigReaderDerivation extends ConfigReaderDerivation:
object HintsAwareConfigReaderDerivation extends HintsAwareConfigReaderDerivation:
object syntax:
extension (c: ConfigReader.type)
inline def derived[A](using Mirror.Of[A], ProductHint[A], CoproductHint[A]): ConfigReader[A] = deriveReader[A]
Expand Up @@ -8,8 +8,8 @@ import scala.deriving.Mirror
import pureconfig.error.{CannotConvert, ConfigReaderFailures}
import pureconfig.generic.error.InvalidCoproductOption

trait CoproductConfigReaderDerivation:
self: ConfigReaderDerivation =>
trait HintsAwareCoproductConfigReaderDerivation:
self: HintsAwareConfigReaderDerivation =>

inline def deriveSumReader[A](using m: Mirror.SumOf[A], ch: CoproductHint[A], ph: ProductHint[A]): ConfigReader[A] =
new ConfigReader[A]:
Expand Down
Expand Up @@ -12,8 +12,8 @@ import pureconfig.generic.ProductHint.UseOrDefault
import pureconfig.generic.derivation.Utils
import pureconfig.generic.derivation.Utils.widen

trait ProductConfigReaderDerivation:
self: ConfigReaderDerivation =>
trait HintsAwareProductConfigReaderDerivation:
self: HintsAwareConfigReaderDerivation =>

inline def deriveProductReader[A](using
m: Mirror.ProductOf[A],
Expand Down
Expand Up @@ -3,4 +3,4 @@ package pureconfig.generic
import pureconfig.generic.derivation.*

object semiauto:
export ConfigReaderDerivation.deriveReader
export HintsAwareConfigReaderDerivation.deriveReader

0 comments on commit 8e5c5b9

Please sign in to comment.