Skip to content

Instantly share code, notes, and snippets.

@stephenjudkins
Created August 20, 2013 18:00
Show Gist options
  • Save stephenjudkins/6284917 to your computer and use it in GitHub Desktop.
Save stephenjudkins/6284917 to your computer and use it in GitHub Desktop.
trait HListContains[-H <: HList, A] { def apply(h: H):A }
implicit def headContains[A, T <: HList] = new HListContains[A :: T, A] {
def apply(h: A :: T) = h.head
}
implicit def tailContains[A, H, T <: HList](implicit tc: HListContains[T, A]) = new HListContains[H :: T, A] {
def apply(h: H :: T) = tc(h.tail)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment