From 873dc895ab9c059fa80c34d43e13228c5049ae9d Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 12 Sep 2007 11:09:09 +0000 Subject: [PATCH] foldl1' was added to Data.List in GHC 6.4.x --- compiler/nativeGen/RegSpillClean.hs | 3 ++- compiler/utils/Util.lhs | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/compiler/nativeGen/RegSpillClean.hs b/compiler/nativeGen/RegSpillClean.hs index ea36a5e..47ded08 100644 --- a/compiler/nativeGen/RegSpillClean.hs +++ b/compiler/nativeGen/RegSpillClean.hs @@ -39,9 +39,10 @@ import UniqFM import Unique import State import Outputable +import Util import Data.Maybe -import Data.List +import Data.List ( nub ) -- | Clean out unneeded spill/reloads from this top level thing. cleanSpills :: LiveCmmTop -> LiveCmmTop diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 2d5e740..6cefad6 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -20,6 +20,7 @@ module Util ( mapFst, mapSnd, mapAndUnzip, mapAndUnzip3, nOfThem, filterOut, partitionWith, splitEithers, + foldl1', lengthExceeds, lengthIs, lengthAtLeast, listLengthCmp, atLength, equalLength, compareLength, @@ -88,8 +89,8 @@ module Util ( import FastTypes -#ifdef DEBUG -import Panic ( panic, trace ) +#if defined(DEBUG) || __GLASGOW_HASKELL__ < 604 +import Panic #endif import Control.Exception ( Exception(..), finally, catchDyn, throw ) @@ -98,11 +99,10 @@ import Data.Dynamic ( Typeable ) import Data.IORef ( IORef, newIORef ) import System.IO.Unsafe ( unsafePerformIO ) import Data.IORef ( readIORef, writeIORef ) +import Data.List hiding (group) import qualified Data.List as List ( elem ) -#ifndef DEBUG -import Data.List ( zipWith4 ) -#else +#ifdef DEBUG import qualified Data.List as List ( notElem ) #endif @@ -363,6 +363,16 @@ isn'tIn msg x ys # endif /* DEBUG */ \end{code} +foldl1' was added in GHC 6.4 + +\begin{code} +#if __GLASGOW_HASKELL__ < 604 +foldl1' :: (a -> a -> a) -> [a] -> a +foldl1' f (x:xs) = foldl' f x xs +foldl1' _ [] = panic "foldl1'" +#endif +\end{code} + %************************************************************************ %* * \subsubsection[Utils-Carsten-mergesort]{A mergesort from Carsten} -- 1.7.10.4