1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TwoLengthString

Last updated at Posted at 2012-12-26
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
  }
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?