[Haskell-cafe] how to get a string from file
haskell at benmachine.co.uk
Wed Mar 3 17:24:48 EST 2010
On Wed, Mar 3, 2010 at 6:30 PM, Thomas DuBuisson
<thomas.dubuisson at gmail.com> wrote:
> On Wed, Mar 3, 2010 at 10:26 AM, Pradeep Wickramanayake <pradeep at talk.lk> 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
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Or maybe you just want:
getItemFile = do
test <- readFile "input.txt"
i.e. exactly what you have but without the argument.
This is actually exactly the same as
getItemFile = readFile "input.txt"
More information about the Haskell-Cafe