--- Lu Mudong <[EMAIL PROTECTED]> wrote: > Thanks a lot for you guys' help. > > I am very new to haskell and tried some methods you > guys advised, doesn't > seem to work, i think i didn't do it properly, > here's my code and result, > hope you can point out what's wrong. thanks! >
Lots of theory, here's some code: -- Begin code module Main() where import IO myReadFile :: String -> IO String myReadFile filename = readFile filename main :: IO () main = do s <- myReadFile "/etc/fstab" let length = doStuffWithNormalString s putStr "Length of File :" putStr (show length) putStr "\n" -- For example, count the number of characters doStuffWithNormalString :: String -> Int doStuffWithNormalString s = length s; -- End code My Explination: Basically, your program starts in a do loop. Anything that returns an IO something needs a <-. For example a <- someIOReturnValue And you can use a as a normal value w/o an IO type. Anything function that doesn't return the IO type needs a let a = someNormalFunction. And you can pretty much do what you want after you know these things. Oh yea, you can't do IO stuff in a non IO function. This is a pretty nasty part of learning haskell, but once you get used to it, you might actually like it. Later, David J. Sankel _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell