[Haskell-cafe] [ANNOUNCE] (and request for review): directory-tree v0.9.0

Brandon Simmons brandon.m.simmons at gmail.com
Tue Aug 10 01:48:37 EDT 2010

Greetings Haskellers!

directory-tree is a module providing a directory-tree-like datatype
along with Foldable and Traversable instances, along with a simple,
high-level IO interface. You can see the package along with some
examples here (apologies if the haddock docs haven't been generated
yet) :


This primary change in this release is the addition of two
experimental "lazy" functions: `readDirectoryWithL` and `buildL`.
These functions use `unsafePerformIO` behind the scenes to traverse
the filesystem as required by pure computations consuming the returned
DirTree data structure. I believe I am doing this safely and sanely
but would love if some more experienced folks could comment on the

These changes (and this whole revamping of this originally very simple
module) were inspired by the fact that a few people seemed to really
like this API, and this recent reddit post lamenting the perceived
difficulty of writing a `du`-like function in haskell.


One could write such a function using directory-tree as follows (sorry
if the monadic compositional style is foreign):

> import System.Directory.Tree
> import qualified Data.Foldable as F
> import System.IO
> import Control.Monad
> du :: FileName -> IO ()
> du = print . F.sum . free <=< readDirectoryWithL (hFileSize <=< readHs)
>     where readHs = flip openFile ReadMode

Thanks for reading and for any input, especially performance
suggestions or opinions on my unsafe function usage. I hope this is
useful to someone.

Brandon Simmons

More information about the Haskell-Cafe mailing list