X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FUtil.lhs;h=6cefad645d0e519bb5eb42aed9f861374df0c40f;hb=1a7d1b77334529ca96ed4cbc03fcb5f55dc2de4a;hp=64ed4f1e61223b22aea961625b6efc4b060ebd8a;hpb=17b297d97d327620ed6bfab942f8992b2446f1bf;p=ghc-hetmet.git diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 64ed4f1..6cefad6 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -5,11 +5,11 @@ \section[Util]{Highly random utility functions} \begin{code} -{-# OPTIONS_GHC -w #-} +{-# OPTIONS -w #-} -- The above warning supression flag is a temporary kludge. -- While working on this module you are encouraged to remove it and fix -- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details module Util ( @@ -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}