You are viewing a single comment's thread. Return to all comments →
HackerRank tells you all you need to know about the input, so it's a completely different situation from an arbitrary CLI. This approach works for the type of problems on this particular site, and for the typical use case where input comes from a terminating program or a file.
It actually won't run forever because of a handy thing called EOF.
Nice idea about the type sig, though.
how would you write
ms <- forM [1..n] $ const $ getLine
let d = M.fromList $ (\[x,y] -> (x,y)) . words <$> ms
on one line?
d <- M.fromList <$> map ((\[x,y] -> (x,y)) . words) <$> replicateM n getLine