[Haskell-cafe] unexpected behavior from filterM doesFileExist =<< getDirectoryContents

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sun Jan 10 00:30:31 EST 2010


On Jan 10, 2010, at 00:24 , Thomas Hartman wrote:
> Can somebody explain this?
>
>> getDirectoryContents inD
>
> ["..","#sanity
> .txt
> #",".","sanity
> .txt
> ","etc
> .txt
> ","patchTagDir
> .txt
> ","jail
> .txt","notjail.txt","alldata.txt","allobjs.txt","namesNSizes.txt"]
>
>> filterM doesFileExist =<< getDirectoryContents inD
>
>> ["sanity.txt"]


My first guess is that inD isn't "."; getDirectoryContents doesn't  
fully qualify the names it returns, so doesFileExist looks in the  
current directory for the bare names returned.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100110/cc9e84a4/PGP.bin


More information about the Haskell-Cafe mailing list