Read an integer list in Haskell
Posted on December 24, 2013
Was browsing my feed and came across something similar to this in stack overflow. So really quickly wrote out the imperative version:
readInts :: String -> [Int]
readInts x = read x
main = do
input <- getLine
let list = read input :: [Int]
print list
Then I of course rewrote it to the condensed version:
readInts :: String -> [Int]
readInts x = read x
main = do
getLine >>= print . readInts
I attempted to get rid of the readInts function like this:
main = getLine >>= print . (read :: [Int])
However I was met with the type error and… I apparently never finished this post. Maybe later?