X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=utils%2Fnofib-analyse%2FGenUtils.lhs;h=8bc9957b0d2834c55fc9078f3285b278d54523d2;hp=540199f972f583cc89198ae8484d9ed9e07b763b;hb=e6e36c2b65e936dc73d57b2f29b7cff84b0cbb4e;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1 diff --git a/utils/nofib-analyse/GenUtils.lhs b/utils/nofib-analyse/GenUtils.lhs index 540199f..8bc9957 100644 --- a/utils/nofib-analyse/GenUtils.lhs +++ b/utils/nofib-analyse/GenUtils.lhs @@ -85,7 +85,7 @@ HBC has it in one of its builtin modules > maybeMap :: (a -> b) -> Maybe a -> Maybe b > maybeMap f (Just a) = Just (f a) -> maybeMap f Nothing = Nothing +> maybeMap _ Nothing = Nothing > joinMaybe :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a > joinMaybe _ Nothing Nothing = Nothing @@ -102,12 +102,12 @@ This will never terminate. > mkClosure :: (a -> a -> Bool) -> (a -> a) -> a -> a > mkClosure eq f = match . iterate f > where -> match (a:b:c) | a `eq` b = a +> match (a:b:_) | a `eq` b = a > match (_:c) = match c > foldb :: (a -> a -> a) -> [a] -> a -> foldb f [] = error "can't reduce an empty list using foldb" -> foldb f [x] = x +> foldb _ [] = error "can't reduce an empty list using foldb" +> foldb _ [x] = x > foldb f l = foldb f (foldb' l) > where > foldb' (x:y:x':y':xs) = f (f x y) (f x' y') : foldb' xs @@ -133,7 +133,7 @@ Sorting is something almost every program needs, and this is the quickest sorting function I know of. > sortWith :: (a -> a -> Bool) -> [a] -> [a] -> sortWith le [] = [] +> sortWith _ [] = [] > sortWith le lst = foldb (mergeWith le) (splitList lst) > where > splitList (a1:a2:a3:a4:a5:xs) = @@ -163,7 +163,7 @@ Gofer-like stuff: > fst3 (a,_,_) = a > snd3 (_,a,_) = a -> thd3 (_,a,_) = a +> thd3 (_,_,a) = a > cjustify, ljustify, rjustify :: Int -> String -> String > cjustify n s = space halfm ++ s ++ space (m - halfm)