[Haskell-cafe] Filesystem questions

Yitzchak Gale gale at sefer.org
Sun Oct 14 06:43:38 EDT 2007

I wrote:
>>> ...a tool for recursing through directories...
>>> How about a built-in function that represents a directory tree
>>> as a lazy Data.Tree?

Bryan O'Sullivan wrote:
>> See System.FilePath.Find in
>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FileManip-0.2

> -- List all directories in the tree rooted at the given path
> traverseDirectories :: MonadIO m =>
>   TraversalDirection -> FilePath -> ListT m Directory
> You could plug the above into your machinery for
> "recursion predicates" and all the other nice stuff.

Or - getting back to the "lazy Data.Tree" idea -
we could define TreeT, analgous to ListT:

newtype TreeT m a = NodeT (m (a, TreeT (ListT m) a))

and give it a nice Monad instance. Then you can prune
and filter trees in a natural way, inside the monad.


More information about the Haskell-Cafe mailing list