@alehander42 What @trtt is trying to implement is called an HList, and is a 
common construction in, say, Haskell or Scala.

This is an [example of implementation in 
Scala]([https://apocalisp.wordpress.com/2010/07/06/type-level-programming-in-scala-part-6a-heterogeneous-list%C2%A0basics/)](https://apocalisp.wordpress.com/2010/07/06/type-level-programming-in-scala-part-6a-heterogeneous-list%C2%A0basics/\)),
 this is [the actual 
implementation]([https://github.com/milessabin/shapeless/blob/master/core/src/main/scala/shapeless/hlists.scala](https://github.com/milessabin/shapeless/blob/master/core/src/main/scala/shapeless/hlists.scala))
 in a popular library, and this is [a blog 
post]([http://rnduja.github.io/2016/01/19/a_shapeless_primer/#hlists-and-product-types](http://rnduja.github.io/2016/01/19/a_shapeless_primer/#hlists-and-product-types))
 introducing the feature.

I copy the basic implementation here as an example
    
    
    sealed trait HList
    
    final case class HCons[H, T <: HList](head : H, tail : T) extends HList {
       def ::[T](v : T) = HCons(v, this)
    }
    
    sealed class HNil extends HList {
       def ::[T](v : T) = HCons(v, this)
    }
    
    // aliases for building HList types and for pattern matching
    object HList {
      type ::[H, T <: HList] = HCons
      val :: = HCons
    }
    
    
    Run

Reply via email to