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 more utilities to strong-path #48

Open
craigmc08 opened this issue Jul 18, 2023 · 2 comments
Open

Add more utilities to strong-path #48

craigmc08 opened this issue Jul 18, 2023 · 2 comments

Comments

@craigmc08
Copy link

The path library offers a bunch more utility functions (https://hackage.haskell.org/package/path-0.9.2/docs/Path-Posix.html#g:4) that strong-path would benefit from having. Currently, to do things like work with extensions you have to convert to a path Path, use functions from that library, and then back to a strong-path Path.

@Martinsos
Copy link
Member

@craigmc08 you implemented some of these, could you paste implementations here or in other relevant issues (there are some open already)?

@craigmc08
Copy link
Author

Implementing these functions just needs a bit of wrapping/unwrapping code to use the functions from path. Here are the ones I've implemented:

stripProperPrefix :: MonadThrow m => Path' b (Dir d) -> Path' b (File f) -> m (Path' (Rel d) (File f))
stripProperPrefix base file =
  fromPathRelFile
    <$> Path.stripProperPrefix (toPathAbsDir base) (toPathAbsFile file)

replaceExtension :: MonadThrow m => String -> Path' b (File f) -> m (Path' b (File f))
replaceExtension ext path =
  fromPathAbsFile <$> Path.replaceExtension ext (toPathAbsFile path)

And I see #40 is related.

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

No branches or pull requests

2 participants