3 ms·
You can either type the return value at the end of your line: xs <- map read <$> lines <$> getContents :: IO [Int] Or you can force the xs type on some ot
by marcosdumay 9y ago
You can either type the return value at the end of your line:
xs <- map read <$> lines <$> getContents :: IO [Int]
Or you can force the xs type on some other line:
let _ = xs :: Int
There is a recent idiom for that last format that lets you write on the same line as the expression. I think it's something like:
(xs @ [Int]) <- map read <$> lines <$> getContents
But I haven't used it yet and I am not sure exactly what version of GHC allows it.
- dmytrish 9y agoToday I learned that `:: IO [Int]` at the end of an expression is applied to the whole expression. Thanks!