Previously, splitFunTy was used, which assumes a function type, while a
type argument is applied to a forall type instead of a function type.
Using applyTypeToArg handles all this for us.
beta (App (Case scrut b ty alts) arg) = change $ Case scrut b ty' alts'
where
alts' = map (\(con, bndrs, expr) -> (con, bndrs, (App expr arg))) alts
- (_, ty') = Type.splitFunTy ty
+ ty' = CoreUtils.applyTypeToArg ty arg
-- Leave all other expressions unchanged
beta expr = return expr
-- Perform this transform everywhere