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 ()"<br><br>aa :: String -> String<br>aa instr = do<br>
putStrLn "abc"<br> putStrLn "abc"<br> return "Az"<br><br> Couldn't match expected type `[t]' against inferred type `IO ()'<br> In the expression: putStrLn "abc"<br>
In a 'do' expression: putStrLn "abc"<br> In the expression:<br> do putStrLn "abc"<br> putStrLn "abc"<br> return "Az"<br><br><div><span class="gmail_quote">
On 9/24/07, <b class="gmail_sendername">Sam Hughes</b> <<a href="mailto:hughes@rpi.edu">hughes@rpi.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
John Wicket wrote:<br>> I am still in an imperative way of thinking. In this example here; how<br>> would I call "putStrLn" and then set the function with a value. Eg:<br>><br>> aa :: String -> IO ()
<br>> aa instr = do<br>> putStrLn "abc"<br>> putStrLn "abc"<br>> return "123"<br>><br>> --- The error I am getting.<br>><br>> Couldn't match expected type `()' against inferred type `[Char]'
<br>> In the first argument of `return', namely `"123"'<br>> In the expression: return "123"<br>> In the expression:<br>> do putStrLn "abc"<br>> putStrLn "abc"
<br>> return "123"<br><br>Your type signature is wrong. If you want an IO action whose return<br>value is a String, say so:<br><br>aa :: String -> IO String<br></blockquote></div><br>