directory-tree: A simple directory-like tree datatype, with useful IO functions
A simple directory-like tree datatype, with useful IO functions and Foldable and Traversable instance
Provides a simple data structure mirroring a directory tree on the filesystem, as well as useful functions for reading and writing file and directory structures in the IO monad.
Importing the library and optional (useful) Foldable and Traverable libraries:
import System.Directory.Tree import qualified Data.Foldable as F import qualified Data.Traversable as T
Write a hand-made directory tree of textfiles (strings) to the disk. Simulates creating a new user Tux's home directory on a unix machine:
writeDirectory$ "/home" :/ Dir "Tux" [File "README" "Welcome!"]
"read" a directory by opening all the files at a filepath with readFile, returning an 'AnchoredDirTree String' (d2). Then check for any IO failures:
do (base :/ d2) <- readDirectory "../parent_dir/dir2/" let failed = anyFailed d2 if failed then ...
Use Foldable instance function to concat a directory dir
of text files into a
single file under the same directory:
do (b :/ dt) <- readDirectory dir let f = F.concat dt return$ b :/ File "ALL_TEXT" f
Open all the files in the current directory as lazy bytestrings, ignoring the base path in Anchored wrapper:
import qualified Data.ByteString.Lazy as B do (_ :/ dTree) <- readDirectoryWith B.readFile "./"
Please send me any comments, requests or bug reports
Downloads
- directory-tree-0.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1, 0.1.1, 0.1.2, 0.2.0, 0.2.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1 |
---|---|
Dependencies | base [details] |
Tested with | ghc ==6.8.2 |
License | BSD-3-Clause |
Copyright | (c) 2009, Brandon Simmons <brandon.m.simmons@gmail.com> |
Author | Brandon Simmons |
Maintainer | Brandon Simmons <brandon.m.simmons@gmail.com> |
Category | Data, System |
Home page | http://coder.bsimmons.name/blog/2009/05/directory-tree-module-released/ |
Uploaded | by BrandonSimmons at 2009-05-09T16:02:32Z |
Distributions | Debian:0.12.1, FreeBSD:0.12.0, LTSHaskell:0.12.1, NixOS:0.12.1, Stackage:0.12.1 |
Reverse Dependencies | 19 direct, 204 indirect [details] |
Downloads | 37422 total (21 in the last 30 days) |
Rating | 2.25 (votes: 2) [estimated by Bayesian average] |
Your Rating | |
Status | Docs not available [build log] All reported builds failed as of 2017-01-01 [all 7 reports] |