[Haskell-cafe] walking a directory tree efficiently

Manlio Perillo manlio_perillo at libero.it
Wed Jan 14 09:49:21 EST 2009

Don Stewart ha scritto:
> manlio_perillo:
>> Hi.
>> During a tentative (quite unsuccessfull) to convert a simple Python 
>> script that prints on stdout a directory and all its subdirectory [1] in 
>> a good Haskell (mostly to start to do real practice with the language), 
>> I came across this blog post:
>> http://blog.moertel.com/articles/2007/03/28/directory-tree-printing-in-haskell-part-three-lazy-i-o
>> Since recently I read about alternatives to lazy IO (like iteratee), I'm 
>> curious to know if a flexible, efficient and safe alternative exists, 
>> for the task of display a directory tree.
>> [1] http://paste.pocoo.org/show/99523/
> If you can do it with strict IO in Python, do the same thing in Haskell
> with System.IO.Strict. 
> It should be mechanical to translate Python
> programs directly into naive IO-based Haskell using strict IO. Boring,
> but mechanical.

But that's not the purpose of what I'm doing ;).

I'm trying to practice with Haskell, by converting small Python scripts 
I have written.
I hope, in future, to write a "big" program in Haskell.

> There's no iteratee/fold-based IO system yet.

Yes, I know.

By the way, I have managed to have a working program:

I would like to receive some advices:
1) I have avoided the do notation, using functions like liftM.
    Is this a good practice?
    Is this as efficient as using do notation?
2) I have written some support functions: mapM' and filterM'
    Are they well written and generic?
    Are they already available in some package?
    Can you suggest better names?
3) I find
    (,) node `liftM` walkTree' path
    not very readable.
    Is it possible to express it in a more (not too much) verbose way?

Thanks  Manlio Perillo

More information about the Haskell-Cafe mailing list