A typeclass approach for default values in Scala. The topic of much scorn in Haskell, I find the existence of this typeclass to be superior to the general use Monoid everywhere as though it was a default value.
Default exists to allow you to have something that expresses what you want, even if it might not be what you actually need.
Default exists as a typeclass that allows Default[A].default: A
, it exposes in the package object def default[A: Default]: A
which you will likely find useful to remove the ceremony of summoning the typeclass to use.
To use this project in an existing SBT project with Scala 2.11 or a later version, add the following dependencies to your
build.sbt
depending on your needs:
libraryDependencies ++= Seq(
"io.chrisdavenport" %% "default" % "<version>"
)