Giter Site home page Giter Site logo

Zipper support? about directory-tree HOT 4 CLOSED

jberryman avatar jberryman commented on August 24, 2024
Zipper support?

from directory-tree.

Comments (4)

jberryman avatar jberryman commented on August 24, 2024

Neat! Can you implement it as a new package dependent on directory-tree?

from directory-tree.

hasufell avatar hasufell commented on August 24, 2024

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.

jberryman avatar jberryman commented on August 24, 2024

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.

hasufell avatar hasufell commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.