This is the definition of Nat in package shapeless:
trait Nat {
type N <: Nat
}
case class Succ[P <: Nat]() extends Nat {
type N = Succ[P]
}
class _0 extends Nat with Serializable {
type N = _0
}
What are the type declarations for ?
Once removed it seems to me that the definition works equally well.
They're used where
Natis the target type of an implicit conversion from a literalInt... see here, for example, in the definition of theIntindexing method forHList,Here the intention is that the method is invoked with a literal
Intargument,The argument is converted to a
Natby an implicit macro which is able to inspect the compile time argument tree and construct the correspondingNatvalue. We can then refer to the type memberNofnand use it as an index for theAttype class which extracts the desired element from theHList.