delightful-typeclasses
is Scala a library containing utility typeclasses.
This library is built for Scala 2.12.15, 2.13.8 and 3.1.2
libraryDependencies += "org.sweet-delights" %% "delightful-typeclasses" % "0.2.0"
<dependency>
<groupId>org.sweet-delights</groupId>
<artifactId>delightful-typeclasses_2.12</artifactId>
<version>0.2.0</version>
</dependency>
All files in delightful-typeclasses
are under the GNU Lesser General Public License version 3.
Please read files COPYING
and COPYING.LESSER
for details.
The Default[T]
typeclass creates a default instance of T
.
Step 1: define case classes
import java.time.LocalDateTime
case class Foo(
opt: Option[Int],
str: String,
double: Double,
more: List[Bar]
)
case class Bar(
list: List[LocalDateTime]
)
Step 2: instantiate!
val default = Default[Foo]
println(default)
// Foo(
// opt = Some(0),
// str = "",
// double = "0.0",
// List(
// Bar(List(LocalDateTime.parse("1970-01-01T00:00:00.000")))
// )
// )
- the
shapeless
library - the The Type Astronaut's Guide to Shapeless book
- the Scala 3 documentation