Reputation: 34119
I am reading the book shapeless and follow the examples.
On chapter 4, there is an example about, how to read the second element of HList
.
The code
import shapeless.{HList, ::, HNil}
trait Second[L <: HList] {
type Out
def apply(value: L): Out
}
object Second {
type Aux[L <: HList, O] = Second[L] {type Out = O}
def apply[L <: HList](implicit inst: Second[L]): Aux[L, inst.Out] =
inst
}
object Main {
def main(args: Array[String]): Unit = {
}
}
The compiler complains:
I copy and paste the code from book one to one and can not configure it out, where is the error.
Please help me to find it.
Upvotes: 0
Views: 116
Reputation: 51723
It's not the compiler but your IDE complains (is it IntelliJ?).
If you compile (Ctrl+Shift+F9 / ⌘+Shift+F9) or run (Ctrl+Shift+F10 / ⌘+Shift+F10) your code you'll see it compiles perfectly fine.
You should get used to have some valid Scala code mis-underlined by IDE in red.
This is the way to convince your IDE:
def apply[L <: HList, O](implicit inst: Second.Aux[L, O]): Aux[L, O] = inst
Upvotes: 1