-
Notifications
You must be signed in to change notification settings - Fork 531
Migration guide: shapeless 2.0.0 to 2.1.0
shapeless-2.1.0 is largely backwards source compatible with shapeless-2.0.0, however you might need to make some minor changes as documented below. You might also find the complete set of differences in shapeless's examples and tests between 2.0.0 and 2.1.0 a useful guide to what's involved in updating. They can be found in this commit.
- [TypeClass changes]
The type class deriving infrastructure included in shapeless-2.0.0 has been significantly reworked in shapeless-2.1.0.
It is now implemented entierly in terms of the Generic
and Lazy
type class primitives. Some applications which
required more flexibility that TypeClass
could provide can now be implemented directly in terms of those primitives
and general Scala implicit-based type level computation as seen throughout shapeless.
Applications already using the shapeless-2.0.0 TypeClass
infrastructure will need the following minor modifications,
- Removal of
auto._
imports.
Previously type class instances were only derived automatically in scopes where a wildcard import from the auto
member of the type classes companion object. This mechanism didn't transfer over well to the new implementation and in
any case experience showed it to be overly verbose while adding little value.
- Implicit
TypeClass
member replace bytypeClass
object in type class companion.
Where previously the type class derivation rules where introduced via an implicit definition of the form,
object Show {
implicit val showInstance: ProductTypeClass[Show] = new LabelledTypeClass[Show] {
def emptyProduct = ...
def product ...
def emptyCoproduct = ...
def coproduct ...
def project ...
}
}
they are now introduced via a nested object named typeClass
,
object Show {
object typeClass extends LabelledTypeClass[Show] {
def emptyProduct = ...
def product ...
def emptyCoproduct = ...
def coproduct ...
def project ...
}
}