Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function deleteSubmap #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

QuietJoon
Copy link

Could you add this new function?

I've been used text-trie for many use case, and I implement a function for myself like

deleteSubmap' key trie =
    foldr
        (\k t -> delete k t)
        trie
        (map L.toStrict . keys $ submap key trie)

However, because it traverses every deleting target entries, this version is too slow.

Could you add my implementation in the Data.Trie.Text.Internal?

I'm not sure that the function's name and actual implementation is proper for your package.
If you care, please rename&change it.

@michaeljklein
Copy link
Owner

Hi, thank you for your PR!

This package is almost exactly a clone of bytestring-trie, so I'm trying not to diverge from it. If you get it added to bytestring-trie, I'll update this repo. Otherwise, I think this should go in a text-trie-ext or similar utilities library. (I'd be happy to link to it from the readme if you end up going that route.)

@QuietJoon
Copy link
Author

Actually, I'm using both bytestring-trie and text-trie.
I've already requested PR to bytestring-trie after this PR for text-trie. But the repository seems not to be managed well...

Anyway, I don't think that making a new package text-trie-ext is a good idea because I couldn't access some of the constructors by importing Data.Trie.Text.Internal (for example, Branch) for pattern matching.
If I couldn't access it, the function would not be efficient.
If you don't mind and couldn't wait for bytestring-trie, then please update your repo. (I'm now using my own branch it with etra-deps)

@michaeljklein
Copy link
Owner

If you provide a PR that just exposes the internal constructers you need, I'll merge it. Otherwise, I'd rather wait for bytestring-trie.

@QuietJoon
Copy link
Author

bytestring-trie have been updated which covers my old PR from v0.2.6.
Could you update your text-trie from on this new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants