main must have type IO a. Hoogle tells me that to convert [IO a] -> IO [a], you should use the function sequence. Try applying that to your final line.
On Mon, 9 Mar 2015 16:07 Geoffrey Bays <charioteer7@gmail.com> wrote:_______________________________________________GeoffreyThanks,What does the declared type need to be for a final line of:But with [putStrLn $ show s | s <- newList] as the final line, [IO ()] in the function declaration will not compile, I get this error:My main function looks like this:With this final line, putStrLn $ show (newList !! 0), the type IO () in the function declaration compiles fine.
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)
Couldn't match expected type `IO t0' with actual type `[IO ()]'
[putStrLn $ show s | s <- newList] ???
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners