I have some types based on formless HLists:
type t1 = Int :: String :: Int :: HNil
type t2 = String :: String :: Int :: HNil
I would like to define a sealed attribute ST, which is a super-type for all of them, so if I have the following function:
def fun(x:ST) = β¦
The following conditions are true:
fun(5 :: "foo" :: 3 :: HNil)
fun("foo" :: "bar" :: 42 :: HNil)
but the following does not compile:
fun(5 :: 3 :: HNil)
How to determine t1and t2how subtypes ST?
UPDATE
I think Coproducts might be the solution
type ST = t1 :+: t2 :+: CNil
fun(Coproduct[ST](5 :: "foo" :: 3 :: HNil)) // compiles
fun(Coproduct[ST](5 :: 3 :: HNil)) // does not compile
source
share