From: simonpj Date: Fri, 4 Jan 2002 10:25:33 +0000 (+0000) Subject: [project @ 2002-01-04 10:25:33 by simonpj] X-Git-Tag: Approximately_9120_patches~326 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=dad9aa43e3a1ca884585c5465cbd55d71715a572;p=ghc-hetmet.git [project @ 2002-01-04 10:25:33 by simonpj] Warn, dont crash, when isIn gets a big list --- diff --git a/ghc/compiler/utils/Util.lhs b/ghc/compiler/utils/Util.lhs index 51f53f3..8c86eea 100644 --- a/ghc/compiler/utils/Util.lhs +++ b/ghc/compiler/utils/Util.lhs @@ -69,9 +69,10 @@ module Util ( #include "../includes/config.h" #include "HsVersions.h" +import qualified List ( elem, notElem ) import List ( zipWith4 ) import Maybe ( Maybe(..) ) -import Panic ( panic ) +import Panic ( panic, trace ) import IOExts ( IORef, newIORef, unsafePerformIO ) import FastTypes #if __GLASGOW_HASKELL__ <= 408 @@ -317,19 +318,19 @@ isIn msg x ys where elem i _ [] = False elem i x (y:ys) - | i ># _ILIT 100 = panic ("Over-long elem in: " ++ msg) - | otherwise = x == y || elem (i +# _ILIT(1)) x ys + | i ># _ILIT 100 = trace ("Over-long elem in " ++ msg) $ + x `List.elem` (y:ys) + | otherwise = x == y || elem (i +# _ILIT(1)) x ys isn'tIn msg x ys = notElem (_ILIT 0) x ys where notElem i x [] = True notElem i x (y:ys) - | i ># _ILIT 100 = panic ("Over-long notElem in: " ++ msg) - | otherwise = x /= y && notElem (i +# _ILIT(1)) x ys - + | i ># _ILIT 100 = trace ("Over-long notElem in " ++ msg) $ + x `List.notElem` (y:ys) + | otherwise = x /= y && notElem (i +# _ILIT(1)) x ys # endif {- DEBUG -} - \end{code} %************************************************************************