Comments (4)
Neat! Can you implement it as a new package dependent on directory-tree
?
from directory-tree.
I'm not sure I need this any more. I got performance problems with finding things in the contents
list for huge directories. The lazy representation of the filesystem tree carried too much state around which also became a problem. The strict representation was even moreso problematic when reading stuff like "/", so I ended up doing things more atomically:
data AnchoredDirTree a b =
(:/) { anchor :: FilePath, dirTree :: IntMap (DirTree a b) }
deriving (Eq, Ord, Show)
data DirTree a b =
Failed {
name :: FileName
, err :: IOException
}
| Dir {
name :: FileName
, dir :: a
}
| File {
name :: FileName
, file :: b
} deriving (Show, Eq)
But that's out of the scope of this library. I'm not sure how useful a Zipper actually is.
Representing the filesystem is really difficult since it's an almost random state that can change so quickly that your code-objects that are meant to represent this state may already be out of date.
I don't see a way to keep a complete lazy filesystem tree up to date, do you? As soon as you have looked at a node in the tree, it's static. And if you re-read the filesystem lazily every time you "enter" a subdirectory, then it's a moot point and probably safer to do that explicitly and not depend on the implicit IO through laziness.
from directory-tree.
You're right, doing lazy IO with a directory tree is inherently weird; it works very nicely for certain applications where you assume the directory isn't changing, and other times it comes with all the usual problems of lazy IO on files, but moreso. Anyway thanks for sharing your experiments. You might see if there are some new solutions on hackage based on streaming libraries that can do what you need. (I'm not really familiar with what's out there these days in this space).
from directory-tree.
Yeah, I'm having a look at https://hackage.haskell.org/package/conduit-extra-1.1.9.2/docs/Data-Conduit-Filesystem.html which looks interesting. Guess I'll have to learn conduits then :)
from directory-tree.
Related Issues (11)
- Add free variable to Dir? HOT 2
- Use `unsafeInterleaveIO` instead of `unsafePerformIO` HOT 1
- EXAMPLES/Examples.hs dependencies missing.
- Infinite loop when symlink refers to parent dir
- suggestion: add a function to simply collect recursivley the filenames in a directory HOT 1
- latest GHC support HOT 1
- Reading the filename implies reading the whole file HOT 4
- Test suite failure HOT 3
- Bifunctor support? HOT 3
- Weird behavior on /dev/fd with readDirectoryWithL HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directory-tree.