[Haskell-beginners] Processing a list of files the Haskell way
Michael Schober
Micha-Schober at web.de
Tue Mar 13 16:34:10 CET 2012
Hi again,
I'm still trying to figure out my earlier problem regarding the
directory tree and functions on the files.
What I'm really trying to do sounds simple enough: find duplicate files
for a complete directory, given a root. The original approach I had in
mind was to compute every file's checksum, which I could feed into a map
of (checksums,[filepaths]).
On 03/10/2012 01:48 PM, Chaddaï Fouché wrote:
> Note that you solution isn't very "functional-like", but rather
> imperative. On the other hand, making it more functional in this
> particular case come with its own brand of subtle difficulties.
I now wonder how to achieve my goal properly in Haskell. Obviously I
have some sequential parts of my program (reading directory trees is I/O
and therefore monadic), but it seems to me that could also be some
functional part as well (pairing files with checksums, pairing checksums
with common filepaths, filtering only checksums with more than one
filepath, maybe even sorting, etc.).
How would you go about to do it? Which parts of the program should be
monadic, which functional? Would you create a custom-build monad or
would you use build-ins (which ones?)?
I would really like to have some pointers how an experienced Haskell
developer would go about such a thing, since I want to acquire a Haskell
feel of programming rather than keep on programming in my old ways, now
in Haskell. I would also be happy to be simply pinpointed to other
applications which source code are exemplary, but not too huge to dig
through in a sensible amount of time. (I'm currently trying to work
through the Darcs source code, but that seems a bit too overkill.)
Thanks for any comments and thoughts.
Best,
Michael
More information about the Beginners
mailing list