I don't think by shape is a good idea, especially the either/validated part shows that. I think inline classes are worth exploring for that. You get unions at runtime and classes at compile time for typeclasses resolution. So that either becomes an inline class over a union and validated as well, same representation, maybe some magic in the union plugin to allow same expressivity but typeclasses by actual type instead of rep