summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2006-12-12 17:43:10 +0000
committerIan Lynagh <igloo@earth.li>2006-12-12 17:43:10 +0000
commit2bac92995f3d23f713b9811c9acf32f288dc1485 (patch)
tree089bd66af7600b3c9fd19dbf7bd69e8cdfc53fcc /utils
parente550eefe55f029207f842e55e30addca15988146 (diff)
downloadhaskell-2bac92995f3d23f713b9811c9acf32f288dc1485.tar.gz
Fix more warnings
Diffstat (limited to 'utils')
-rw-r--r--utils/nofib-analyse/GenUtils.lhs62
1 files changed, 11 insertions, 51 deletions
diff --git a/utils/nofib-analyse/GenUtils.lhs b/utils/nofib-analyse/GenUtils.lhs
index a54584466a..6a1fb768e3 100644
--- a/utils/nofib-analyse/GenUtils.lhs
+++ b/utils/nofib-analyse/GenUtils.lhs
@@ -104,6 +104,7 @@ This will never terminate.
> where
> match (a:b:_) | a `eq` b = a
> match (_:c) = match c
+> match [] = error "GenUtils.mkClosure: Can't happen"
> foldb :: (a -> a -> a) -> [a] -> a
> foldb _ [] = error "can't reduce an empty list using foldb"
@@ -161,9 +162,12 @@ quickest sorting function I know of.
Gofer-like stuff:
-> fst3 (a,_,_) = a
-> snd3 (_,a,_) = a
-> thd3 (_,_,a) = a
+> fst3 :: (a, b, c) -> a
+> fst3 (a, _, _) = a
+> snd3 :: (a, b, c) -> b
+> snd3 (_, a, _) = a
+> thd3 :: (a, b, c) -> c
+> thd3 (_, _, a) = a
> cjustify, ljustify, rjustify :: Int -> String -> String
> cjustify n s = space halfm ++ s ++ space (m - halfm)
@@ -180,13 +184,14 @@ Gofer-like stuff:
> copy n x = take n xs where xs = x:xs
> partition' :: (Eq b) => (a -> b) -> [a] -> [[a]]
-> partition' f [] = []
-> partition' f [x] = [[x]]
+> partition' _ [] = []
+> partition' _ [x] = [[x]]
> partition' f (x:x':xs) | f x == f x'
> = tack x (partition' f (x':xs))
> | otherwise
> = [x] : partition' f (x':xs)
+> tack :: a -> [[a]] -> [[a]]
> tack x xss = (x : head xss) : tail xss
> combinePairs :: (Ord a) => [(a,b)] -> [(a,[b])]
@@ -221,8 +226,7 @@ Gofer-like stuff:
> assocMaybeErr :: (Eq a) => [(a,b)] -> a -> MaybeErr b String
> assocMaybeErr env k = case [ val | (key,val) <- env, k == key] of
> [] -> Failed "assoc: "
-> (val:vs) -> Succeeded val
->
+> (val:_) -> Succeeded val
Now some utilties involving arrays.
Here is a version of @elem@ that uses partual application
@@ -251,47 +255,3 @@ will give a very efficent variation of the fib function.
> memoise bds f = (!) arr
> where arr = array bds [ ASSOC(t, f t) | t <- range bds ]
-> 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
-
-> 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
-
-Here is the bi-directional version ...
-
-> 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 accumulator 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
-
-
-> assert False x = error "assert Failed"
-> assert True x = x