trait LabelledGeneric[T] extends Serializable
LabelledGeneric is similar to Generic, but includes information about field names or class names in addition to the raw structure.
Continuing the example from shadedshapeless.Generic, we use LabelledGeneric to convert an object to an shadedshapeless.HList:
scala> val lgenDog = LabelledGeneric[Dog] lgenDog: shadedshapeless.LabelledGeneric[Dog]{ type Repr = Record.`'name -> String, 'bonesHidden -> Int`.T } = ... scala> lgenDog.to(odie) res15: lgenDog.Repr = odie :: 3 :: HNil
Note that the representation does not include the labels! The labels are actually encoded in the generic type representation using shadedshapeless.Witness types.
As with shadedshapeless.Generic, the representation for Animal captures the subclass embedding rather than the fields in the class, using shadedshapeless.Coproduct:
scala> val lgenAnimal = LabelledGeneric[Animal] lgenAnimal: shadedshapeless.LabelledGeneric[Animal]{ type Repr = Union.`'Cat -> Cat, 'Dog -> Dog`.T } = ... scala> lgenAnimal.to(odie) res16: lgenAnimal.Repr = Dog(odie,3) scala> genAnimal.to(odie) match { case Inr(Inl(dog)) => dog ; case _ => ???} res19: Dog = Dog(odie,3)
- T
the type which this instance can convert to and from a labelled generic representation
- Alphabetic
- By Inheritance
- LabelledGeneric
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
abstract
type
Repr
The generic representation type for {T}, which will be composed of {Coproduct} and {HList} types
Abstract Value Members
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )