How to Check whether a file exists and IO[String] vs [String]

Alexandre Weffort Thenorio alethenorio@home.se
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
getting:

Action: openFile
Reason: No such file or directory
File: ./nagrarom.txt

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"

Again thanks.

Best Regards

NooK
----- Original Message ----- 
From: "Derek Elkins" <ddarius@hotpop.com>
To: "Alexandre Weffort Thenorio" <alethenorio@home.se>
Cc: <haskell-cafe@haskell.org>
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" <alethenorio@home.se> 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
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>