[commit: ghc] master: Simplify mergeSATInfo by using zipWith (93b8d0f)

git at git.haskell.org git at git.haskell.org
Wed Oct 1 16:21:46 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/93b8d0fd63cf8e00ca37c1ce76b93d4ee1fc56f8/ghc

>---------------------------------------------------------------

commit 93b8d0fd63cf8e00ca37c1ce76b93d4ee1fc56f8
Author: David Feuer <David.Feuer at gmail.com>
Date:   Wed Oct 1 16:02:45 2014 +0200

    Simplify mergeSATInfo by using zipWith
    
    Closes #9561.


>---------------------------------------------------------------

93b8d0fd63cf8e00ca37c1ce76b93d4ee1fc56f8
 compiler/simplCore/SAT.lhs | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/compiler/simplCore/SAT.lhs b/compiler/simplCore/SAT.lhs
index f973c35..bd5b718 100644
--- a/compiler/simplCore/SAT.lhs
+++ b/compiler/simplCore/SAT.lhs
@@ -139,15 +139,24 @@ pprStaticness NotStatic            = ptext (sLit "NS")
 
 
 mergeSATInfo :: SATInfo -> SATInfo -> SATInfo
-mergeSATInfo [] _  = []
-mergeSATInfo _  [] = []
-mergeSATInfo (NotStatic:statics) (_:apps) = NotStatic : mergeSATInfo statics apps
-mergeSATInfo (_:statics) (NotStatic:apps) = NotStatic : mergeSATInfo statics apps
-mergeSATInfo ((Static (VarApp v)):statics)  ((Static (VarApp v')):apps)  = (if v == v' then Static (VarApp v) else NotStatic) : mergeSATInfo statics apps
-mergeSATInfo ((Static (TypeApp t)):statics) ((Static (TypeApp t')):apps) = (if t `eqType` t' then Static (TypeApp t) else NotStatic) : mergeSATInfo statics apps
-mergeSATInfo ((Static (CoApp c)):statics) ((Static (CoApp c')):apps)     = (if c `coreEqCoercion` c' then Static (CoApp c) else NotStatic) : mergeSATInfo statics apps
-mergeSATInfo l  r  = pprPanic "mergeSATInfo" $ ptext (sLit "Left:") <> pprSATInfo l <> ptext (sLit ", ")
-                                            <> ptext (sLit "Right:") <> pprSATInfo r
+mergeSATInfo l r = zipWith mergeSA l r
+  where
+    mergeSA NotStatic _ = NotStatic
+    mergeSA _ NotStatic = NotStatic
+    mergeSA (Static (VarApp v)) (Static (VarApp v'))
+      | v == v'   = Static (VarApp v)
+      | otherwise = NotStatic
+    mergeSA (Static (TypeApp t)) (Static (TypeApp t'))
+      | t `eqType` t' = Static (TypeApp t)
+      | otherwise     = NotStatic
+    mergeSA (Static (CoApp c)) (Static (CoApp c'))
+      | c `coreEqCoercion` c' = Static (CoApp c)
+      | otherwise             = NotStatic
+    mergeSA _ _  = pprPanic "mergeSATInfo" $
+                          ptext (sLit "Left:")
+                       <> pprSATInfo l <> ptext (sLit ", ")
+                       <> ptext (sLit "Right:")
+                       <> pprSATInfo r
 
 mergeIdSATInfo :: IdSATInfo -> IdSATInfo -> IdSATInfo
 mergeIdSATInfo = plusUFM_C mergeSATInfo



More information about the ghc-commits mailing list