-splitRepTyConApp_maybe is like splitTyConApp_maybe except
-that it looks through
- (a) for-alls, and
- (b) newtypes
-in addition to synonyms. It's useful in the back end where we're not
-interested in newtypes anymore.
-
-\begin{code}
-splitRepTyConApp_maybe :: Type -> Maybe (TyCon, [Type])
-splitRepTyConApp_maybe (FunTy arg res) = Just (funTyCon, [arg,res])
-splitRepTyConApp_maybe (NoteTy _ ty) = splitRepTyConApp_maybe ty
-splitRepTyConApp_maybe (ForAllTy _ ty) = splitRepTyConApp_maybe ty
-splitRepTyConApp_maybe (TyConApp tc tys)
- | isNewTyCon tc
- = case splitFunTy_maybe (applyTys (dataConType (head (tyConDataCons tc))) tys) of
- Just (rep_ty, _) -> splitRepTyConApp_maybe rep_ty
- | otherwise
- = Just (tc,tys)
-splitRepTyConApp_maybe other = Nothing
-\end{code}
-