Comments (3)
Yeah, I definitely understand your use case. A possibly better (in the context of the library) way to do this might be to change Dir
to:
| Dir {
dir :: a -- formerly `name :: FileName`
, contents :: [DirTree a b]
}
And this could mirror our functions that already work on and manipulate DirTree FileName
, which would instead work on DirTree FileName FileName
.
Then we might want to simply remove the records (since those partial records aren't very nice). And add a function (a shim for users of name
):
name :: DirTree FileName a -> FileName
And I think rather than a BiFunctor
instance, we might provide a newtype wrapper like:
-- not a great name:
newtype DirectoryView files dirs = DirectoryView (DirTree dirs files)
And provide all the relevant instances we can for that type.
Let me know what you think and let's stew on this for a bit.
from directory-tree.
That sounds interesting, but I have two thoughts about that:
- about
name :: DirTree FileName a -> FileName
: I'd go so far to consider makingFileName
a newtype (API breakage :/ )... because it is justString
and ourdir
record can have Strings of arbitrary meaning and isn't as explicit as the previousname :: FileName
record anymore - I'm not entirely sure if this wouldn't limit the API for my use case (and possibily others), since any library function that wants to operate on directory and file names, must have the type
DirTree FileName FileName
type if I am not mistaken? Then people would have to create wrappers around those functions if they want to use it, because their types might be different, since they want to use thedir :: a
record for something else. I think thedropTo
function for example would be affected by this.
from directory-tree.
dropTo
would have the type
dropTo :: FileName -> AnchoredDirTree Filename a -> Maybe Filename (AnchoredDirTree a)
other functions could be polymorphic in that new first variable.
from directory-tree.
Related Issues (10)
- Add free variable to Dir? HOT 2
- Zipper support? HOT 4
- 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
- Reading the filename implies reading the whole file HOT 4
- Test suite failure 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.