[Haskell-beginners] GHC not buying what I am offering this afternoon
Geoffrey Bays
charioteer7 at gmail.com
Mon Mar 9 20:07:23 UTC 2015
My main function looks like this:
main :: [IO()]
main = do
let stud1 = Student {name = "Geoff", average = -99.0, grades =
[66,77,88]}
let stud2 = Student {name = "Doug", average = -99.0, grades =
[77,88,99]}
let stud3 = Student {name = "Ron", average = -99.0, grades = [55,66,77]}
let studList = [stud1,stud2]
let newList = calcAvg studList
[putStrLn $ show s | s <- newList]
--putStrLn $ show (newList !! 0)
--putStrLn $ show (newList !! 1)
With this final line, putStrLn $ show (newList !! 0), the type IO () in the
function declaration compiles fine.
But with [putStrLn $ show s | s <- newList] as the final line, [IO ()] in
the function declaration will not compile, I get this error:
Couldn't match expected type `IO t0' with actual type `[IO ()]'
What does the declared type need to be for a final line of:
[putStrLn $ show s | s <- newList] ???
Thanks,
Geoffrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150309/c2bab9f6/attachment.html>
More information about the Beginners
mailing list