This works:
c <- fmap lines (readFile "d:\\tmp\\h.txt")
let h = map (read :: String -> Int) c
while "superposition" of those two lines those not compile
fmap (read :: String -> Int) $ fmap lines (readFile "d:\\tmp\\h.txt")
it generates error:
interactive:1:36: Couldn't match expected type `Char' with actual type `[Char]' Expected type: String -> String Actual type: String -> [String] In the first argument of `fmap', namely `lines' In the second argument of `($)', namely `fmap lines (readFile "d:\\tmp\\h.txt")
Why it does not compile and how to do this in one line? What I want is achieve a simplicity of python
[int(i) for i in open("d:\\tmp\\h.txt")]