Follow up question

Andre W B Furtado aw@free.elogica.com.br
Tue, 3 Apr 2001 00:35:05 -0300


Perhaps the following code will fit your purpose:

main :: IO ()
main = do
    file <- readFile "c:/myfile.txt"
    word <- getWordIO file

getWordIO :: String -> IO String
getWordIO word = return (getWord word)

Where getWord is the same you defined. You can also try:

main :: IO ()
main = readFile "c:/myfile.txt" >>=  \file -> getWordIO file

Notice that ConvertString wouldn't work because functions must not start
with capital letters :)

Andre

----- Original Message -----
From: <MikeKn22@aol.com>
To: <haskell@haskell.org>
Sent: Monday, April 02, 2001 10:41 PM
Subject: Follow up question


> I am a bit confused by your response Mieszko.  What I am looking to do is
have a function say called
>
> ConvertString :: IO String -> String
>
> or something like that.  Not sure if your examples achieve this.  I want
to take the IO String and be able to use it as a String somehow.  My problem
is I have a function for instance
>
> getWord :: String -> String
> getWord [] = []
> getWord (x:xs)
>     | elem x whitespace = []
>     | otherwise         = x : getWord xs
>
> If I change the header to
>
> getWord :: IO String -> IO String
>
> I get errors of types not matching.  Sorry if these are stupid questions
but I am very confused by the difference of IO String and String, and want
to know how you can use the IO String like a String.  Thank you.
>
> Rob
>
>
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>