
On Thu, May 8, 2008 at 10:59 PM, Mark Wallsgrove wrote:
Thank you very much for your fast response!
Ok, that is now changed, but everything else in my program is expecting Catalogue without IO. Is there a way to change IO Catalogue into Catalogue?
Suppose I have a function "readFile" of type String -> IO String, and a function "read" of type String -> Catalogue. How can I feed the output of the first function into the second function, when that pesky "IO" is in my way? Perhaps I would write something that looks like this: loadData :: String -> IO Catalogue loadData fileName = do x <- readFile fileName return (read x :: Catalogue) Even though the expression "readFile fileName" has type IO String, the variable "x" bound on the third line has type String. This means that I can pass it into "read" without any problems. Eventually you'll learn about things like (>>=) and "liftM", which can be used to write this in a simpler form, but hopefully this will get you going for now. Stuart