I’m working on a module called DirectoryTree, a simple tree structure
mirroring the structure of a directory tree in the
outside world, with functions to hopefully
make it easy to do useful things (I’m not sure if something like this already
exists). Here is the data-type:
1 2 3 4 | |
I would like to do things like map over a DirTree of FilePaths, returning
a tree (in the IO monad) of Handles… so the code involves a lot of
slogging through the IO monad, which I’m not totally comfortable with yet.
I’m feeling out how to proceed with the above and begin to define this function:
1 2 | |
…there’s something happening here but I don’t know what it is; let’s see what Hoogle can tell me about this abstraction. I take the type definition and plug it into firefox’s hoogle search plugin and voila!; I’m presented with the following matches:
1 2 3 4 5 | |
I see that
mapM
from Data.Traversable looks like what I want, and traverse also looks useful.
I learned something, and have an idea of how to proceed, and that’s why I love hoogle :)