All Downloads are FREE. Search and download functionalities are using the official Maven repository.

caseapp.core.default.Default.scala Maven / Gradle / Ivy

There is a newer version: 2.0.0-M8
Show newest version
package caseapp.core.default

import caseapp.{@@, Tag}
import caseapp.core.Counter

/**
  * Default value for type `T`
  *
  * Allows to give fields of type `T` a default value, even if none was explicitly specified.
  */
final case class Default[T](value: T) extends AnyVal

object Default {

  implicit def option[T]: Default[Option[T]] =
    Default(None)

  implicit def list[T]: Default[List[T]] =
    Default(Nil)

  implicit def vector[T]: Default[Vector[T]] =
    Default(Vector.empty)

  implicit val counter: Default[Int @@ Counter] =
    Default(Tag.of(0))

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy