X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Futils%2FUtil.lhs;fp=compiler%2Futils%2FUtil.lhs;h=af811104762c0fb7fc99252ee6755dc2a9945514;hp=db6f96a206d92315186ca3f777268bcf5edb83fe;hb=1c15bee5a8fc004c16693d7d7a2d95b442549b66;hpb=97d5e75a63afc329096d94c74760415c586f7cec 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