Skip to content

Instantly share code, notes, and snippets.

@akimichi
Created May 1, 2012 04:06
Show Gist options
  • Save akimichi/2564924 to your computer and use it in GitHub Desktop.
Save akimichi/2564924 to your computer and use it in GitHub Desktop.
HList
sealed trait HList {}
final case class HCons[H, T <: HList](head : H, tail : T) extends HList {
def ::[T](v : T) = HCons(v,this)
override def toString = head + " :: " + tail
}
final class HNil extends HList {
def ::[T](v : T) = HCons(v,this)
override def toString = "Nil"
}
object HList {
type ::[H, T <: HList] = HCons[H,T]
val :: = HCons
val HNil = new HNil
}
// vim: set ts=4 sw=4 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment