Created
July 4, 2019 04:37
-
-
Save p-pavel/ca20053a7d4ce6d7d353f648cab89960 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait HList { | |
def ::[A](x: A): A :: this.type | |
} | |
trait ::[+Head, +Tail <: HList] extends HList { | |
val head: Head | |
val tail: Tail | |
def ::[A](x: A): A :: this.type = HCons(x,this) | |
} | |
final case class HCons[+Head, +Tail <: HList](head: Head, tail: Tail) extends (Head :: Tail) { | |
override def toString: String = s"$head :: $tail" | |
} | |
trait HNil extends HList | |
final case object HNil extends HNil { | |
def ::[A](x: A): A :: this.type = HCons(x, this) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment