Skip to content

Instantly share code, notes, and snippets.

@cb372
Created January 13, 2021 10:18
Show Gist options
  • Save cb372/da77e9704be531c4fa65b7481a34c5a1 to your computer and use it in GitHub Desktop.
Save cb372/da77e9704be531c4fa65b7481a34c5a1 to your computer and use it in GitHub Desktop.
DTList
import scala.compiletime.S
sealed trait DTList[N <: Int]:
inline def size: N = valueOf[N]
def +:[H](h: H): DTNonEmptyList[N, H, this.type] =
DTNonEmptyList(h, this)
case object DTNil extends DTList[0]
case class DTNonEmptyList[N <: Int, H, T <: DTList[N]](
head: H, tail: T) extends DTList[S[N]]
val list = 1 +: "two" +: DTNil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment