X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fprelude%2FPrelRules.lhs;h=c7d5e1a64c78115e4543d1cd4ce3a4796e18d5fa;hb=a127213c1890584702075d732d7bb9887113e4ff;hp=c22f57264a640601b2c3c80229b60f1da5f14480;hpb=111cee3f1ad93816cb828e38b38521d85c3bcebb;p=ghc-hetmet.git diff --git a/ghc/compiler/prelude/PrelRules.lhs b/ghc/compiler/prelude/PrelRules.lhs index c22f572..c7d5e1a 100644 --- a/ghc/compiler/prelude/PrelRules.lhs +++ b/ghc/compiler/prelude/PrelRules.lhs @@ -23,7 +23,7 @@ import TysWiredIn ( trueDataConId, falseDataConId ) import TyCon ( tyConDataCons, isEnumerationTyCon, isNewTyCon ) import DataCon ( DataCon, dataConTag, dataConRepArity, dataConTyCon, dataConId, fIRST_TAG ) import CoreUnfold ( maybeUnfoldingTemplate ) -import CoreUtils ( exprIsValue, cheapEqExpr ) +import CoreUtils ( exprIsValue, cheapEqExpr, exprIsConApp_maybe ) import Type ( splitTyConApp_maybe ) import OccName ( occNameUserString) import ThinAir ( unpackCStringFoldrId ) @@ -370,31 +370,14 @@ For dataToTag#, we can reduce if either \begin{code} dataToTagRule [_, val_arg] - = case maybeConApp val_arg of - Just dc -> ASSERT( not (isNewTyCon (dataConTyCon dc)) ) - Just (SLIT("DataToTag"), - mkIntVal (toInteger (dataConTag dc - fIRST_TAG))) + = case exprIsConApp_maybe val_arg of + Just (dc,_) -> ASSERT( not (isNewTyCon (dataConTyCon dc)) ) + Just (SLIT("DataToTag"), + mkIntVal (toInteger (dataConTag dc - fIRST_TAG))) - other -> Nothing + other -> Nothing dataToTagRule other = Nothing - -maybeConApp :: CoreExpr -> Maybe DataCon -maybeConApp (Var v) - = case maybeUnfoldingTemplate (idUnfolding v) of - Just unf -> maybeConApp unf - Nothing -> Nothing - -maybeConApp expr - = go expr 0 - where - go (App f a) n | isTypeArg a = go f n - | otherwise = go f (n+1) - go (Var f) n = case isDataConId_maybe f of - Just dc -> ASSERT( n == dataConRepArity dc ) - Just dc -- Check it's saturated - other -> Nothing - go other n = Nothing \end{code} %************************************************************************