I am once again asking for a standardized SealedMa...
# advent-of-code
m
I am once again asking for a standardized SealedMap implementation like an EnumMap
my string reducer returns either an illegal class(with the character that was illegal) or an incomplete class(with the list thats left after reducing it)
Copy code
sealed interface Type{
    @JvmInline value class Incomplete(val list: List<Char>) : Type
    @JvmInline value class Illegal(val char: Char) : Type
}
My function returns this Type. Now for part one, I'd want the illegal parts of this list, and for part two I want the incomplete parts. My assumption is that you can just map it to a map, and because sealed classes have known subclasses, you should just be able to do map[Illegal] or map[Incomplete]. But now I have to do that, but still filter the instances of the values to the correct types
p
Wait that really compiles? Having value classes as subclasses of sealed interfaces? Uff
m
Yeah why wouldn't it? You can have anything that inherents interfaces as subclasses of a sealed interface
e
just look at stdlib, UIntArray implements Collection<UInt>