<HTML><HEAD><META content="text/html; charset=UTF-8" http-equiv="Content-Type"></HEAD><BODY>It's not a file permission problem because it works great when the file exists. But, when the file doesn't exist, it still tries to read the file. It acts like the file is there when it isn't. In ghci, it returns the true boolean when the file is there and a false when it isn't. But, in the program, it is always executing the readFile.<BR>
<BR>
Kim-Ee Yeoh wrote:<BR>
<blockquote type="cite"><BR>
<BR>
On Wed, Mar 4, 2015 at 12:38 PM, Richard Guay <raguay@customct.com <BR>
<mailto:raguay@customct.com>> wrote:<BR>
<BR>
        fExist <- doesFileExist $ h ++ cacheDirBasic ++ getBundleID ++<BR>
    "/" ++ fileName<BR>
        if fExist<BR>
        then do<BR>
            contents <- readFile $ h ++ cacheDirBasic ++ getBundleID<BR>
    ++ "/" ++ fileName<BR>
<BR>
<BR>
First of all, let's refactor that into a let binding, e.g.<BR>
<BR>
    let pathName = h ++ cacheDirBasic ++ getBundleID ++ "/" ++ fileName<BR>
    fExist <- doesFileExist pathName<BR>
    if fExist then readFile pathName else return ""<BR>
<BR>
The advantage of keeping DRY here should be obvious. Defining the same <BR>
thing in 2 places can lead to both getting out of lockstep.<BR>
<BR>
Now as for debugging the actual problem, have you tried the REPL? That <BR>
is, launch ghci, load the appropriate libraries, and see what happens <BR>
when you enter<BR>
<BR>
doesFileExist "/home/me/myfile"<BR>
<BR>
and similarly for readFile. That way you'd rule things out like a file <BR>
permissions problem, etc.<BR>
<BR>
<BR>
-- Kim-Ee<BR>
_______________________________________________<BR>
Beginners mailing list<BR>
Beginners@haskell.org<BR>
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</BODY></HTML>