
getItemFile :: IO String getItemFile test = do test <- readFile "input.txt" return test this is the program I did to take a file and get all the data from that file to a string. Can someone help me. I get this error Type error in explicitly typed binding *** Term : getItemFile *** Type : a -> IO [Char] *** Does not match : IO String What I need is to get the file to a string and then get it to a tuple by checking each places where the file contain a blank space Please help me Thanks

On Wed, Mar 3, 2010 at 10:26 AM, Pradeep Wickramanayake
getItemFile :: IO String
This says getItemFile is an action that returns a string. No arguments.
getItemFile test = ...
And your implementation obviously requires a file path as an argument. You wanted a type signature of: getItemFile :: FilePath -> IO String or perhaps more simply (FilePath is just an alias for String): getItemFile :: String -> IO String Cheers, Thomas

On Wed, Mar 3, 2010 at 6:30 PM, Thomas DuBuisson
On Wed, Mar 3, 2010 at 10:26 AM, Pradeep Wickramanayake
wrote: getItemFile :: IO String
This says getItemFile is an action that returns a string. No arguments.
getItemFile test = ...
And your implementation obviously requires a file path as an argument. You wanted a type signature of:
getItemFile :: FilePath -> IO String
or perhaps more simply (FilePath is just an alias for String):
getItemFile :: String -> IO String
Cheers, Thomas _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Or maybe you just want: getItemFile = do test <- readFile "input.txt" return test i.e. exactly what you have but without the argument. This is actually exactly the same as getItemFile = readFile "input.txt"
participants (3)
-
Ben Millwood
-
Pradeep Wickramanayake
-
Thomas DuBuisson