factor out common tc-branch pattern of looking at various branches and matching their types; rewrite tc-if with this
rename parameters before checking compatibility between the type in cases() against the variant constructor, so that parametric functions that use the same parameter name don't confuse things