Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 2.29 KB

README.md

File metadata and controls

45 lines (36 loc) · 2.29 KB

Java typeclasses

Type classes example in Java. Inspired by Scala example (slides), Typeclasses

  • In Haskell, typeclass is the language feature.
  • In Scala, typeclass is a pattern.
  • In Java, typeclass is a experiment.

A type class is a type system construct that supports ad hoc polymorphism. This is achieved by adding constraints to type variables in parametrically polymorphic types. Such a constraint typically involves a type class T and a type variable a, and means that a can only be instantiated to a type whose members support the overloaded operations associated with T. Wikipedia

In this code Scala implicits are replaced by Spring DI. Case classes are created with Lombok @Value and matched by javaslang-match.

Requirements

Goals

Run

  • ./gradlew test