[commit: ghc] wip/validate-T9561: Simplify mergeSATInfo by using zipWith (7599458)

git at git.haskell.org git at git.haskell.org
Wed Oct 1 14:03:31 UTC 2014


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

On branch  : wip/validate-T9561
Link       : http://ghc.haskell.org/trac/ghc/changeset/7599458dc577535377e45ae7ae0993d93cdab8ad/ghc

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

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

    Simplify mergeSATInfo by using zipWith
    
    Closes #9561.


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

7599458dc577535377e45ae7ae0993d93cdab8ad
 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