Well aa isn't returning a string. It's returning a function for later evaluation which encapsulates the string. It's like driving anywhere in California. You can't get there following the road signs unless you've driven there once before. In this case the road signs say "return a string" but the way to get their is "return a string encapsulated in a function". The error message ("you can't get there from here") is then straightforward.

  -ljr

Andrew Coppin wrote:
aa :: String -> String
aa instr = do
  putStrLn "abc"
  putStrLn "abc"
  return "Az"

>> Couldn't match expected type `[t]' against inferred type `IO ()'


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...)



--
Lanny Ripple <[EMAIL PROTECTED]>
ScmDB / Cisco Systems, Inc.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to