object HList {
sealed trait HList
final class HNil extends HList {
def ::[T](v : T) = HCons(v, this)
}
val HNil = new HNil()
final case class HCons[H, T <: HList](head : H, tail : T) extends HList {
def ::[T](v : T) = HCons(v, this)
}
type ::[H, T <: HList] = HCons[H, T]
type TwoLengthString = Char :: Char :: HNil
implicit def stringToTwoLengthString(s:String) = {
s.head :: s.last :: HNil
}
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme