Skip to content

Instantly share code, notes, and snippets.

@matt-martin
Created March 29, 2015 01:06
Show Gist options
  • Save matt-martin/5dec770a65ad12303ac1 to your computer and use it in GitHub Desktop.
Save matt-martin/5dec770a65ad12303ac1 to your computer and use it in GitHub Desktop.
Why do these implicits only work for single element HLists?
implicit def hNilToList[L <: HNil](l : L) : List[Any] = Nil
implicit def hListToList[H <: Any, T <: HList](l : H :: T)(implicit conv : T => List[Any]) : List[Any] = {
l.head :: conv(l.tail)
}
hListToList("foo" :: HNil)
//res23: List[Any] = List(foo)
hListToList("foo" :: "bar" :: HNil)
//<console>:36: error: type mismatch;
// found : List[Any]
// required: shapeless.::[?,?]
// hListToList("foo" :: "bar" :: HNil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment