From 262c142b90c94ca1aa577c950a6ceae1f255e2d6 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Mon, 2 Jul 2007 12:26:51 +0000 Subject: [PATCH] Remove mapAccumL, mapAccumR, mapAccumB mapAccumL and mapAccumR are in Data.List now. mapAccumB is unused. --- compiler/codeGen/CgClosure.lhs | 2 ++ compiler/codeGen/CgHeapery.lhs | 2 ++ compiler/codeGen/CgMonad.lhs | 1 + compiler/coreSyn/CoreSubst.lhs | 2 ++ compiler/coreSyn/CoreTidy.lhs | 2 ++ compiler/deSugar/DsArrows.lhs | 2 ++ compiler/iface/BinIface.hs | 1 + compiler/simplCore/CSE.lhs | 4 ++- compiler/simplCore/OccurAnal.lhs | 4 ++- compiler/simplCore/SimplEnv.lhs | 2 ++ compiler/specialise/Rules.lhs | 2 +- compiler/stranal/DmdAnal.lhs | 4 ++- compiler/typecheck/Inst.lhs | 2 ++ compiler/typecheck/TcTyClsDecls.lhs | 2 +- compiler/types/Type.lhs | 1 + compiler/utils/ListSetOps.lhs | 4 +-- compiler/utils/Util.lhs | 57 ----------------------------------- 17 files changed, 30 insertions(+), 64 deletions(-) diff --git a/compiler/codeGen/CgClosure.lhs b/compiler/codeGen/CgClosure.lhs index 98e5b0d..fabf434 100644 --- a/compiler/codeGen/CgClosure.lhs +++ b/compiler/codeGen/CgClosure.lhs @@ -46,6 +46,8 @@ import BasicTypes import Constants import Outputable import FastString + +import Data.List \end{code} %******************************************************** diff --git a/compiler/codeGen/CgHeapery.lhs b/compiler/codeGen/CgHeapery.lhs index 4a12849..3bba211 100644 --- a/compiler/codeGen/CgHeapery.lhs +++ b/compiler/codeGen/CgHeapery.lhs @@ -45,6 +45,8 @@ import Util import Constants import PackageConfig import Outputable + +import Data.List \end{code} diff --git a/compiler/codeGen/CgMonad.lhs b/compiler/codeGen/CgMonad.lhs index 6885912..8723e46 100644 --- a/compiler/codeGen/CgMonad.lhs +++ b/compiler/codeGen/CgMonad.lhs @@ -79,6 +79,7 @@ import FastString import Outputable import Control.Monad +import Data.List infixr 9 `thenC` -- Right-associative! infixr 9 `thenFC` diff --git a/compiler/coreSyn/CoreSubst.lhs b/compiler/coreSyn/CoreSubst.lhs index 8306c04..1c81d88 100644 --- a/compiler/coreSyn/CoreSubst.lhs +++ b/compiler/coreSyn/CoreSubst.lhs @@ -45,6 +45,8 @@ import Outputable import PprCore () -- Instances import Util import FastTypes + +import Data.List \end{code} diff --git a/compiler/coreSyn/CoreTidy.lhs b/compiler/coreSyn/CoreTidy.lhs index 95c3ac4..ea89fcc 100644 --- a/compiler/coreSyn/CoreTidy.lhs +++ b/compiler/coreSyn/CoreTidy.lhs @@ -26,6 +26,8 @@ import OccName import SrcLoc import Maybes import Util + +import Data.List \end{code} diff --git a/compiler/deSugar/DsArrows.lhs b/compiler/deSugar/DsArrows.lhs index fc2432d..c44ed59 100644 --- a/compiler/deSugar/DsArrows.lhs +++ b/compiler/deSugar/DsArrows.lhs @@ -42,6 +42,8 @@ import Util import HsUtils import VarSet import SrcLoc + +import Data.List \end{code} \begin{code} diff --git a/compiler/iface/BinIface.hs b/compiler/iface/BinIface.hs index 4664bf1..392873b 100644 --- a/compiler/iface/BinIface.hs +++ b/compiler/iface/BinIface.hs @@ -34,6 +34,7 @@ import Config import FastMutInt import Outputable +import Data.List import Data.Word import Data.Array import Data.IORef diff --git a/compiler/simplCore/CSE.lhs b/compiler/simplCore/CSE.lhs index 39344fc..782e564 100644 --- a/compiler/simplCore/CSE.lhs +++ b/compiler/simplCore/CSE.lhs @@ -21,8 +21,10 @@ import CoreLint ( showPass, endPass ) import Outputable import StaticFlags ( opt_PprStyle_Debug ) import BasicTypes ( isAlwaysActive ) -import Util ( mapAccumL, lengthExceeds ) +import Util ( lengthExceeds ) import UniqFM + +import Data.List \end{code} diff --git a/compiler/simplCore/OccurAnal.lhs b/compiler/simplCore/OccurAnal.lhs index dc20fd2..ae2b7b9 100644 --- a/compiler/simplCore/OccurAnal.lhs +++ b/compiler/simplCore/OccurAnal.lhs @@ -35,8 +35,10 @@ import Digraph ( stronglyConnCompR, SCC(..) ) import PrelNames ( buildIdKey, foldrIdKey, runSTRepIdKey, augmentIdKey ) import Unique ( Unique ) import UniqFM ( keysUFM, intersectsUFM ) -import Util ( mapAndUnzip, mapAccumL ) +import Util ( mapAndUnzip ) import Outputable + +import Data.List \end{code} diff --git a/compiler/simplCore/SimplEnv.lhs b/compiler/simplCore/SimplEnv.lhs index 1d7d2e4..6104d33 100644 --- a/compiler/simplCore/SimplEnv.lhs +++ b/compiler/simplCore/SimplEnv.lhs @@ -58,6 +58,8 @@ import BasicTypes import DynFlags import Util import Outputable + +import Data.List \end{code} %************************************************************************ diff --git a/compiler/specialise/Rules.lhs b/compiler/specialise/Rules.lhs index ed9f238..26a499b 100644 --- a/compiler/specialise/Rules.lhs +++ b/compiler/specialise/Rules.lhs @@ -45,7 +45,7 @@ import Maybes import OrdList import Bag import Util -import List hiding( mapAccumL ) -- Also defined in Util +import Data.List \end{code} diff --git a/compiler/stranal/DmdAnal.lhs b/compiler/stranal/DmdAnal.lhs index 4c5de96..84c189e 100644 --- a/compiler/stranal/DmdAnal.lhs +++ b/compiler/stranal/DmdAnal.lhs @@ -43,11 +43,13 @@ import UniqFM ( plusUFM_C, addToUFM_Directly, lookupUFM_Directly, import Type ( isUnLiftedType, coreEqType, splitTyConApp_maybe ) import Coercion ( coercionKind ) import CoreLint ( showPass, endPass ) -import Util ( mapAndUnzip, mapAccumL, mapAccumR, lengthIs ) +import Util ( mapAndUnzip, lengthIs ) import BasicTypes ( Arity, TopLevelFlag(..), isTopLevel, isNeverActive, RecFlag(..), isRec ) import Maybes ( orElse, expectJust ) import Outputable + +import Data.List \end{code} To think about diff --git a/compiler/typecheck/Inst.lhs b/compiler/typecheck/Inst.lhs index 962e4e0..6a09244 100644 --- a/compiler/typecheck/Inst.lhs +++ b/compiler/typecheck/Inst.lhs @@ -76,6 +76,8 @@ import DynFlags import Maybes import Util import Outputable + +import Data.List \end{code} diff --git a/compiler/typecheck/TcTyClsDecls.lhs b/compiler/typecheck/TcTyClsDecls.lhs index 8a07fae..3d2e4ba 100644 --- a/compiler/typecheck/TcTyClsDecls.lhs +++ b/compiler/typecheck/TcTyClsDecls.lhs @@ -44,7 +44,7 @@ import ListSetOps import Digraph import DynFlags -import Data.List ( partition, elemIndex ) +import Data.List import Control.Monad ( mplus ) \end{code} diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs index 37f915b..649baea 100644 --- a/compiler/types/Type.lhs +++ b/compiler/types/Type.lhs @@ -122,6 +122,7 @@ import Util import Outputable import UniqSet +import Data.List import Data.Maybe ( isJust ) \end{code} diff --git a/compiler/utils/ListSetOps.lhs b/compiler/utils/ListSetOps.lhs index becf9e6..29f4bb1 100644 --- a/compiler/utils/ListSetOps.lhs +++ b/compiler/utils/ListSetOps.lhs @@ -24,9 +24,9 @@ module ListSetOps ( import Outputable import Unique ( Unique ) import UniqFM ( eltsUFM, emptyUFM, addToUFM_C ) -import Util ( isn'tIn, isIn, mapAccumR, sortLe ) +import Util ( isn'tIn, isIn, sortLe ) -import Data.List ( partition ) +import Data.List \end{code} diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index abde6d6..1d7f7a4 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -32,7 +32,6 @@ module Util ( transitiveClosure, -- accumulating - mapAccumL, mapAccumR, mapAccumB, foldl2, count, all2, takeList, dropList, splitAtList, split, @@ -488,62 +487,6 @@ transitiveClosure succ eq xs %* * %************************************************************************ -@mapAccumL@ behaves like a combination -of @map@ and @foldl@; -it applies a function to each element of a list, passing an accumulating -parameter from left to right, and returning a final value of this -accumulator together with the new list. - -\begin{code} -mapAccumL :: (acc -> x -> (acc, y)) -- Function of elt of input list - -- and accumulator, returning new - -- accumulator and elt of result list - -> acc -- Initial accumulator - -> [x] -- Input list - -> (acc, [y]) -- Final accumulator and result list - -mapAccumL f b [] = (b, []) -mapAccumL f b (x:xs) = (b'', x':xs') where - (b', x') = f b x - (b'', xs') = mapAccumL f b' xs -\end{code} - -@mapAccumR@ does the same, but working from right to left instead. Its type is -the same as @mapAccumL@, though. - -\begin{code} -mapAccumR :: (acc -> x -> (acc, y)) -- Function of elt of input list - -- and accumulator, returning new - -- accumulator and elt of result list - -> acc -- Initial accumulator - -> [x] -- Input list - -> (acc, [y]) -- Final accumulator and result list - -mapAccumR f b [] = (b, []) -mapAccumR f b (x:xs) = (b'', x':xs') where - (b'', x') = f b' x - (b', xs') = mapAccumR f b xs -\end{code} - -Here is the bi-directional version, that works from both left and right. - -\begin{code} -mapAccumB :: (accl -> accr -> x -> (accl, accr,y)) - -- Function of elt of input list - -- and accumulator, returning new - -- accumulator and elt of result list - -> accl -- Initial accumulator from left - -> accr -- Initial accumulator from right - -> [x] -- Input list - -> (accl, accr, [y]) -- Final accumulators and result list - -mapAccumB f a b [] = (a,b,[]) -mapAccumB f a b (x:xs) = (a'',b'',y:ys) - where - (a',b'',y) = f a b' x - (a'',b',ys) = mapAccumB f a' b xs -\end{code} - A strict version of foldl. \begin{code} -- 1.7.10.4