X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FUtil.lhs;h=af811104762c0fb7fc99252ee6755dc2a9945514;hb=8ffd91b6102f4ad3111cabdf6bdb1998f257887f;hp=db6f96a206d92315186ca3f777268bcf5edb83fe;hpb=af37b3001b086f39cbf1fe3ea2aa5c37f4f9a34f;p=ghc-hetmet.git diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index db6f96a..af81110 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -32,6 +32,7 @@ module Util ( -- * List operations controlled by another list takeList, dropList, splitAtList, split, + dropTail, -- * For loop nTimes, @@ -608,6 +609,10 @@ splitAtList (_:xs) (y:ys) = (y:ys', ys'') where (ys', ys'') = splitAtList xs ys +-- drop from the end of a list +dropTail :: Int -> [a] -> [a] +dropTail n = reverse . drop n . reverse + snocView :: [a] -> Maybe ([a],a) -- Split off the last element snocView [] = Nothing