Created
January 13, 2021 10:18
-
-
Save cb372/da77e9704be531c4fa65b7481a34c5a1 to your computer and use it in GitHub Desktop.
DTList
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
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