[Haskell-cafe] Filesystem questions
gale at sefer.org
Sun Oct 14 15:42:24 EDT 2007
> This is little different from the approach taken by Python's os.walk,
> which lazily yields the contents of a directory tree as it traverses it.
> I'm a little unclear on why one appears good in your eyes, while the
> other is not, beyond perhaps the depth/breadth knob and differences in
> amount of documentation. Maybe you could expand on that a bit?
Well firstly, I never said that your approach is not good.
I was very pleased to see your work on this,
and I was inspired by it.
I do think that it is much better to provide IO laziness
using monad transformers (or whatever) rather than
unsafe IO. The basic difference is that with unsafe IO,
you relinquish control over the order in which things
happen, and leave it to the whims of the compiler/runtime.
Besides the fact that it can always lead to bugs
(viz. the constant problems people have with
readFile and getContents), in this case the
exact order of the side effects happens to
be a critical and delicate issue, so you really
don't want to give up that control here.
My second proposal introduces another
deviation from your approach in that it presents
a full tree view rather than a pre-flattened
tree view. I think that is more natural and
more flexible - just my own taste.
More information about the Haskell-Cafe