[Haskell-cafe] Haskell File reading

cornmouse wing_lucifer at hotmail.com
Tue Mar 6 23:16:11 EST 2007

I have a txt file, which contains a paragraph. I am trying to read the file, 
and pass the contents of the file as a string to another function 
called "createIndex". "createIndex" is a function to generate index of the 
input string.

Below is my code to read the file :

main :: IO ()
     = do
         putStr "Enter input file name.txt: "
         filename <- getLine
         content <- readFile filename
         createIndex content

createIndex  ::  String  ->  [ ([Int], String) ]
       {- contents of the function... -}

I am using Hugs compiler, when i execute, i got an error
Type error in generator
*** Term           : showString content
*** Type           : [Char] -> [Char]
*** Does not match : IO a


I know the data type doesn't match. How do i go about this?

More information about the Haskell-Cafe mailing list