Skip to content

Instantly share code, notes, and snippets.

@rahcola
Created April 12, 2012 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahcola/2370962 to your computer and use it in GitHub Desktop.
Save rahcola/2370962 to your computer and use it in GitHub Desktop.
hFetchLines :: Handle -> [Int] -> IO [String]
hFetchLines h nums = do; end <- hIsEOF h; hFetchLines' nums end 1 []
where
hFetchLines' [] _ _ acc = return acc
hFetchLines' _ False _ acc = return acc
hFetchLines' nums _ row acc = do
line <- hGetLine h
end <- hIsEOF h
if (head nums) == row
then hFetchLines' (tail nums) end (row+1) (line:acc)
else hFetchLines' nums end (row+1) acc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment