Last active
October 5, 2015 03:28
-
-
Save jgcoded/6c7c77938d253baa4ddf to your computer and use it in GitHub Desktop.
Use this snippet to parse any line-delimited user input into a list of a specified type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
If you want to read in Strings: getInputLinesWith id n | |
if you want to read in Ints: getInputLinesWith read n :: IO [Int] | |
where n is how many lines to take input from | |
-} | |
getInputLinesWith :: (String -> a) -> Int -> IO [a] | |
getInputLinesWith f n = fmap (map f) (replicateM n getLine) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment