Second type parameter for filename type, with a typeclass to convert to/from FilePath#18
Open
jefdaj wants to merge 21 commits intojberryman:masterfrom
Open
Second type parameter for filename type, with a typeclass to convert to/from FilePath#18jefdaj wants to merge 21 commits intojberryman:masterfrom
jefdaj wants to merge 21 commits intojberryman:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Waaay back in 2018 I lazy-forked your code (pasted it locally) to see if I could fit larger trees in RAM by changing how filenames are encoded. I found that at least for my use case,
Textwith strictness annotations was better. But I wasn't sure how to contribute that upstream without breaking everyone else'sStrings.I'm finally getting back into Haskell and cleaning up some old code, and had a new idea!
I added a typeclass
IsNamewith the 2-3 functions you would need to supply to work with a new filename type, and a trivial instance forFileName:What do you think??
It turns out not to require much beyond adding another type parameter to all the function signatures.
Test.hsstill passes, and so do all the tests in my code, which uses a newtype wrapper aroundTextinstead. (Confusingly split across two different files here and here)I left the anchors as
FilePathbecause they can have slashes in them, and because I never had a situation where I needed a lot of them so memory use doesn't seem important.If you like it I can clean it up a bit more, remove unrelated changes to the nix flake, comments etc. And/or change the names if you have opinions about them. I just used the first ones that came to mind and weren't confusing versions of "filename" or "path".
I haven't looked at the examples yet. And I commented out all the lens code because I don't understand how to update it. I made a quick attempt in a new branch though and might have gotten close?