Skip to content
Snippets Groups Projects
Commit 0cd517a7 authored by BinderDavid's avatar BinderDavid
Browse files

Avoid partial list functions

parent 9536f107
No related branches found
No related tags found
1 merge request!18Avoid partial list functions
Pipeline #60891 passed
...@@ -15,10 +15,11 @@ dropWhileEndLE p = foldr (\x r -> if null r && p x then [] else x : r) [] ...@@ -15,10 +15,11 @@ dropWhileEndLE p = foldr (\x r -> if null r && p x then [] else x : r) []
grabHpcPos :: Map.Map Int String -> HpcPos -> String grabHpcPos :: Map.Map Int String -> HpcPos -> String
grabHpcPos hsMap srcspan = grabHpcPos hsMap srcspan =
case lns of case lns of
[] -> error "grabHpcPos: invalid source span"
[ln] -> [ln] ->
take ((c2 - c1) + 1) $ drop (c1 - 1) ln take ((c2 - c1) + 1) $ drop (c1 - 1) ln
_ -> hd : tl ->
let lns1 = drop (c1 - 1) (head lns) : tail lns let lns1 = drop (c1 - 1) hd : tl
lns2 = init lns1 ++ [take (c2 + 1) (last lns1)] lns2 = init lns1 ++ [take (c2 + 1) (last lns1)]
in foldl1 (\xs ys -> xs ++ "\n" ++ ys) lns2 in foldl1 (\xs ys -> xs ++ "\n" ++ ys) lns2
where where
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment