An intermediate data structure that carries both the type A
and its representation Repr
.
An intermediate data structure that carries both the type A
and its representation Repr
.
Phantom type describing the structure of A
To sum up: we are given the types of the possible A
values in a Coproduct
structure and we want to
define how to traverse this structure to accumulate all the values in a List
.
sealed trait Foo object Foo { case object Bar extends Foo case object Baz extends Foo val values = Values[Foo] }
All the possible values of A
Derives a Values[A]
instance given a representation Repr
of type A
in terms of Coproduct
, and a given
a ValuesAux[A, Repr]
instance.
Derives a Values[A]
instance given a representation Repr
of type A
in terms of Coproduct
, and a given
a ValuesAux[A, Repr]
instance.
Type of the representation of A
as a Coproduct
.
A Coproduct
is recursively defined as either CNil
or H :+: T
, where T
is a
subtype of Coproduct
.
For instance, a sealed trait that is extended by only one case object Foo
can have the following
representation: Foo.type :+: CNil
.
Isomorphism between A
and Repr
. Shapeless is able to provide such an implicit value for any
sealed type
The companion object contains the machinery to automatically derive the values of a sealed trait extended by case objects only.
Basically, the derivation process is the following:
A
;List
;List
contains all the possible values of typeA
.The first step is the hard part of this process and is actually achieved by shapeless (using macros).