on master help sign in
using accumulator.
dd0e4ceKazu Yamamoto
warp/Network/Wai/Handler/Warp/MultiMap.hs+7−8
@@ -16,8 +16,8 @@ module Network.Wai.Handler.Warp.MultiMap (
16#if __GLASGOW_HASKELL__ < 709
16#if __GLASGOW_HASKELL__ < 709
17import Control.Applicative ((<$>))
17import Control.Applicative ((<$>))
18#endif
18#endif
19−import Data.IntMap (IntMap)
19+import Data.IntMap.Strict (IntMap)
20−import qualified Data.IntMap as I
20+import qualified Data.IntMap.Strict as I
21import qualified Network.Wai.Handler.Warp.Some as S
21import qualified Network.Wai.Handler.Warp.Some as S
22
22
23----------------------------------------------------------------
23----------------------------------------------------------------
@@ -74,15 +74,14 @@ toList m = concatMap f $ I.toAscList m
74pruneWith :: MMap v
74pruneWith :: MMap v
75 -> (v -> IO Bool)
75 -> (v -> IO Bool)
76 -> IO (MMap v)
76 -> IO (MMap v)
77−pruneWith m action = I.fromAscList <$> go (I.toAscList m)
77+pruneWith m action = I.fromAscList <$> go (I.toDescList m) []
78 where
78 where
79− go [] = return []
79+ go [] acc = return acc
80− go ((k,s):kss) = do
80+ go ((k,s):kss) acc = do
81 mt <- S.prune action s
81 mt <- S.prune action s
82− lst <- go kss
83 case mt of
82 case mt of
84− Nothing -> return lst
83+ Nothing -> go kss acc
85− Just t -> return $ (k,t) : lst
84+ Just t -> go kss ((k,t) : acc)
86
85
87----------------------------------------------------------------
86----------------------------------------------------------------
88
87