How to Check whether a file exists and IO[String] vs [String]
Alexandre Weffort Thenorio
Sat, 3 May 2003 00:35:49 +0200
Thanks I read the whole thing and I got what you mean but I solved the
problem with doesFileExist function from Directory library (Read other mail)
although this makes me wonder one thing: How do you know the name of the
error you are getting to put it aside and give a proper error handling just
for that error?? For example out of the page you gave me we have:
getChar' :: IO Char
getChar' = getChar `catch` eofHandler where
eofHandler e = if isEofError e then return '\n' else ioError e
Here the author knows what is the name of the error he wants to put aside
(isEofError) but how can I find out the name of an error that I am getting.
For example when I was getting the problem with file not existing I was
Reason: No such file or directory
But no error name. I tried catching the error and printing out the error
name but was'n't really successfull:
main: catch (do
readFile "xxx.txt") (\e -> putStrLn (show e))
And what I got was
"does not exist"
----- Original Message -----
From: "Derek Elkins" <firstname.lastname@example.org>
To: "Alexandre Weffort Thenorio" <email@example.com>
Sent: Friday, May 02, 2003 11:24 PM
Subject: Re: How to Check whether a file exists and IO[String] vs [String]
> On Fri, 2 May 2003 23:06:36 +0200
> "Alexandre Weffort Thenorio" <firstname.lastname@example.org> wrote:
> > Hello. I am having two problems.
> http://www.haskell.org/tutorial/io.html conveniently answers both. Read
> the rest of it too.
> Haskell-Cafe mailing list