
John Wicket wrote:
Sorry, I was actually trying to use this as an example for something more complicated I am trying to do. In this example, why would the inferred type be "IO ()"
aa :: String -> String aa instr = do putStrLn "abc" putStrLn "abc" return "Az"
Couldn't match expected type `[t]' against inferred type `IO ()' In the expression: putStrLn "abc" In a 'do' expression: putStrLn "abc" In the expression: do putStrLn "abc" putStrLn "abc" return "Az"
If you change that type signature to aa :: String -> IO String then it will work. Any code that does any I/O must have a result type "IO blah". If the code returns no useful information, it will be "IO ()". If, like above, it returns a string, it will be "IO String". And so on. (I must say, that error message doesn't make it terribly clear what the problem is...)