import Name ( isLocalName, setNameUnique )
import SimplMonad
import Type ( Type, tyVarsOfType, tyVarsOfTypes, mkForAllTys, seqType, repType,
- splitTyConApp_maybe, splitAlgTyConApp_maybe, mkTyVarTys, applyTys, splitFunTys, mkFunTys
+ splitTyConApp_maybe, mkTyVarTys, applyTys, splitFunTys, mkFunTys
)
+import TyCon ( tyConDataConsIfAvailable )
import PprType ( {- instance Outputable Type -} )
import DataCon ( dataConRepArity )
import TysPrim ( statePrimTyCon )
-- Note the repType: we want to look through newtypes for this purpose
-canUpdateInPlace ty = case splitAlgTyConApp_maybe (repType ty) of
- Just (_, _, [dc]) -> arity == 1 || arity == 2
- where
- arity = dataConRepArity dc
+canUpdateInPlace ty = case splitTyConApp_maybe (repType ty) of {
+ Nothing -> False ;
+ Just (tycon, _) ->
+
+ case tyConDataConsIfAvailable tycon of
+ [dc] -> arity == 1 || arity == 2
+ where
+ arity = dataConRepArity dc
other -> False
+ }
\end{code}
= returnSmpl rhs
| otherwise -- Consider eta expansion
- = newIds y_tys $ ( \ y_bndrs ->
+ = newIds SLIT("y") y_tys $ ( \ y_bndrs ->
tick (EtaExpansion (head y_bndrs)) `thenSmpl_`
mapAndUnzipSmpl bind_z_arg (args `zip` trivial_args) `thenSmpl` (\ (maybe_z_binds, z_args) ->
returnSmpl (mkLams x_bndrs $
bind_z_arg (arg, trivial_arg)
| trivial_arg = returnSmpl (Nothing, arg)
- | otherwise = newId (exprType arg) $ \ z ->
+ | otherwise = newId SLIT("z") (exprType arg) $ \ z ->
returnSmpl (Just (NonRec z arg), Var z)
-- Note: I used to try to avoid the exprType call by using