Skip to content

Commit

Permalink
Merge 1b95a6c into ddba83f
Browse files Browse the repository at this point in the history
  • Loading branch information
ruippeixotog committed Oct 10, 2018
2 parents ddba83f + 1b95a6c commit c738e34
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Expand Up @@ -15,6 +15,14 @@ trait ProductReaders {
else
cursor.atKey(key).right.flatMap(reader.from))(_(_))

/**
* Builds a `ConfigReader` for an object created from the value of 1 key.
*
* @param f the function converting the read value to the target object
* @tparam B the type of the target object
* @return a `ConfigReader` for an object of type `B` that is created from the value in the
* provided key using `f`.
*/
// Special case because f can't be curried.
final def forProduct1[B, A0](keyA0: String)(f: A0 => B)(implicit
readerA0: ConfigReader[A0]
Expand All @@ -27,7 +35,15 @@ trait ProductReaders {
}
}

[2..22#final def forProduct1[B, [#A0#]]([#keyA0: String#])(f: ([#A0#]) => B)(implicit
[2..22#/**
* Builds a `ConfigReader` for an object created from the values of 1 keys.
*
* @param f the function converting the read values to the target object
* @tparam B the type of the target object
* @return a `ConfigReader` for an object of type `B` that is created from the values in the
* provided keys using `f`.
*/
final def forProduct1[B, [#A0#]]([#keyA0: String#])(f: ([#A0#]) => B)(implicit
[#readerA0: ConfigReader[A0]#]
): ConfigReader[B] = new ConfigReader[B] {
def from(cur: ConfigCursor): Either[ConfigReaderFailures, B] =
Expand Down
Expand Up @@ -17,6 +17,14 @@ trait ProductWriters {
case _ => previousResult.withValue(key, writer.to(value))
}

/**
* Builds a `ConfigWriter` for an object written as 1 key.
*
* @param f the function converting the source object to a value
* @tparam B the type of the source object
* @return a `ConfigWriter` for an object of type `B` that is written as the value
* generated using `f`.
*/
// Special case because we don't want f to be B => Product1[A0].
final def forProduct1[B, A0](keyA0: String)(f: B => A0)(implicit
writerA0: ConfigWriter[A0]
Expand All @@ -29,7 +37,15 @@ trait ProductWriters {
}
}

[2..22#final def forProduct1[B, [#A0#]]([#keyA0: String#])(f: B => Product1[[#A0#]])(implicit
[2..22#/**
* Builds a `ConfigWriter` for an object written as 1 keys.
*
* @param f the function converting the source object to a tuple of values
* @tparam B the type of the source object
* @return a `ConfigWriter` for an object of type `B` that is written as the values
* generated using `f`.
*/
final def forProduct1[B, [#A0#]]([#keyA0: String#])(f: B => Product1[[#A0#]])(implicit
[#writerA0: ConfigWriter[A0]#]
): ConfigWriter[B] = new ConfigWriter[B] {
def to(a: B): ConfigValue = {
Expand Down

0 comments on commit c738e34

Please sign in to comment.