[Haskell-beginners] Couldn't match expected type ‘IO ()’ with actual type [Integer]

Max Voit max.voit+mlhb at with-eyes.net
Thu Feb 5 12:35:11 UTC 2015


On Thu, 05 Feb 2015 13:25:16 +0100
Roelof Wobben <r.wobben at home.nl> wrote:

> Another question :  how can I display the array ?
> 
> putStrln works only for strings,

Yep, so you need to convert it to a string and putStrLn that. Kindly
enough typing ":i []" into ghci tells you, that lists have an instance
for "show".

Anonther option would be to convert every single list element to a
string and putStrLn that. "map" comes in handy here (or mapM_ if you
directly want to use print instead of putStrLn . show).

best,
Max


More information about the Beginners mailing list