0ther wishes from my side (maybe there are other constructs I missed or have been introduced in the meantime):
- have a way to get the value of a singleton type (if doable via Macro):
type T = (1,2,3) val t = singletonValue[T] // t = (1, 2, 3) - Something more for the compiler I guess but I don’t know what can be done with macros by now. Infer the literal types instead of widening (a bit like const assertions in typescript):
val i = const(1) // i is of type 1 and not Int val t = const((1,2,3)) // t is of type (1, 2, 3) and not (Int, Int, Int)` // ideally const would also work when using higher kinded types val l = const(List(1,2,3)) // l is of type List[1 | 2 | 3] and not List[Int] - a function which makes type transformation from tuple to union easy (without the need to repeat it), something like:
where UnionOf could be defined similar to (which results in (x | (y | ..)) which I would like to see flattened for better readability, so (x | y …)type u = UnionOf[Key]type UnionOf[T <: Tuple] = T match case EmptyTuple => Nothing case h *: t => h | UnionOf[t] - ideally UnionOf would be overloaded and would also work for
enumtypes, so that I can define:enum Z: A, B, C, D val e = UnionOf[Z] // e is of type (Z.A | Z.B | Z.C | Z.D) - a way to decompose a union in a match type (we don’t distribute over union types so that is still a possibility I guess). Currently I mainly want this so that I can abstract over enum entry types in a similar way
Z.valuescan somehow (I want to stay on the type level). Maybe there are other means to already achieve this for enum? Nevertheless, I guess being able to decompose a union via match type would allow to define other type utilities such as typescripts exclude.