FIX: mkWWcpr takes open alg types into account
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>
Tue, 2 Oct 2007 13:04:07 +0000 (13:04 +0000)
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>
Tue, 2 Oct 2007 13:04:07 +0000 (13:04 +0000)
- This fixed the failures of GMapAssoc and GMapTop for optmising ways

MERGE TO STABLE

compiler/stranal/WwLib.lhs
compiler/types/Type.lhs

index 31d0990..d066f44 100644 (file)
@@ -27,9 +27,7 @@ import NewDemand      ( Demand(..), DmdResult(..), Demands(..) )
 import MkId            ( realWorldPrimId, voidArgId, mkRuntimeErrorApp, rUNTIME_ERROR_ID,
                           mkUnpackCase, mkProductBox )
 import TysWiredIn      ( tupleCon )
-import Type            ( Type, isUnLiftedType, mkFunTys,
-                         splitForAllTys, splitFunTys, isAlgType
-                       )
+import Type
 import Coercion         ( mkSymCoercion, splitNewTypeRepCo_maybe )
 import BasicTypes      ( Boxity(..) )
 import Var              ( Var, isId )
@@ -422,8 +420,9 @@ mkWWcpr :: Type                              -- function body type
                   Type)                        -- Type of worker's body 
 
 mkWWcpr body_ty RetCPR
-    | not (isAlgType body_ty)
-    = WARN( True, text "mkWWcpr: non-algebraic body type" <+> ppr body_ty )
+    | not (isClosedAlgType body_ty)
+    = WARN( True, 
+            text "mkWWcpr: non-algebraic or open body type" <+> ppr body_ty )
       returnUs (id, id, body_ty)
 
     | n_con_args == 1 && isUnLiftedType con_arg_ty1
index 8c96922..ab47c4c 100644 (file)
@@ -67,8 +67,8 @@ module Type (
        newTyConInstRhs,
 
        -- Lifting and boxity
-       isUnLiftedType, isUnboxedTupleType, isAlgType, isPrimitiveType,
-       isStrictType, isStrictPred, 
+       isUnLiftedType, isUnboxedTupleType, isAlgType, isClosedAlgType,
+       isPrimitiveType, isStrictType, isStrictPred, 
 
        -- Free variables
        tyVarsOfType, tyVarsOfTypes, tyVarsOfPred, tyVarsOfTheta,
@@ -861,10 +861,19 @@ isUnboxedTupleType ty = case splitTyConApp_maybe ty of
 
 -- Should only be applied to *types*; hence the assert
 isAlgType :: Type -> Bool
-isAlgType ty = case splitTyConApp_maybe ty of
-                       Just (tc, ty_args) -> ASSERT( ty_args `lengthIs` tyConArity tc )
-                                             isAlgTyCon tc
-                       other              -> False
+isAlgType ty 
+  = case splitTyConApp_maybe ty of
+      Just (tc, ty_args) -> ASSERT( ty_args `lengthIs` tyConArity tc )
+                           isAlgTyCon tc
+      _other            -> False
+
+-- Should only be applied to *types*; hence the assert
+isClosedAlgType :: Type -> Bool
+isClosedAlgType ty
+  = case splitTyConApp_maybe ty of
+      Just (tc, ty_args) -> ASSERT( ty_args `lengthIs` tyConArity tc )
+                           isAlgTyCon tc && not (isOpenTyCon tc)
+      _other            -> False
 \end{code}
 
 @isStrictType@ computes whether an argument (or let RHS) should