
Il Tue, Sep 12, 2006 at 08:05:42AM -0400, Sara Kenedy ebbe a scrivere:
Hello all,
update :: String -> String update sss = ...
main = do writeFile "myFile.txt" sss x <- callSystem "myFile.txt" y <- openFile "result.txt" ReadMode zzz <- hGetContents y return zzz
I know that function main returns IO String, function update returns String. And my purpose is to get the string zzz from main for the value return of function update. But I do not know which way I can do.
Did you mean something like this? update :: String -> String update sss = "Hi! " ++ sss main = do writeFile "myFile.txt" $ update "What are you trying to do?" x <- callSystem "myFile.txt" y <- openFile "result.txt" ReadMode zzz <- hGetContents y return zzz In this case main :: IO String so you will not see any output (quite useless). I'd suggest you to have a look at this tutorial that explain quite well the IO Monad: http://haskell.org/haskellwiki/IO_inside Ciao Andrea