commercialhaskell / commercialhaskell/path
Add a module with an `OsPath`-typed API
- Dominant language
- Haskell
- Stars
- 129
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
When importing `path`s `OsPath` module, we get either the `PosixPath`- or `WindowsPath`-typed API, depending on our platform. This means that for interactions between our user code and functions of `path`, in order to write portable code, we need to write code handling both `PosixPath` and `WindowsPath` (or a wrapper that translates platform-dependently at compile-time).
But typically nowadays, to write portable code, we prefer using an `OsPath`-typed interfaces everywhere - which does the right thing under-the-hood regardless of what platform we are compiling on. But `path` currently doesn't expose such an interface.
Is there a fundamental reason why not? I read through [the PR introducing the `OsPath` module][pr], but couldn't find anything there.
Otherwise I'd suggest adding a module with `OsPath`-typed functions, e.g. as `OsPath.OsPath`:
```sh
# modules of `path`:
OsPath # type: PosixPath/WindowsPath
OsPath.OsPath # type: OsPath <-- NEW - SUGGESTION
OsPath.Posix # type: PosixPath
OsPath.Windows # type: WindowsPath
Path
# ...
```
It could be useful to study e.g. [file-io][file-io], [directory-ospath-streaming][directory-ospath-streaming] as examples of other packages that include an `OsPath`-typed API (and of course e.g. [filepath][filepath], [directory][directory]).
The implementation should be thin. I'm happy to provide a PR if of interest.
Gently pinging @hasufell who might have opinions around this.
[pr]: https://github.com/commercialhaskell/path/pull/192
[file-io]: https://hackage.haskell.org/package/file-io
[directory-ospath-streaming]: https://hackage.haskell.org/package/directory-ospath-streaming
[filepath]: https://hackage.haskell.org/package/filepath
[directory]: https://hackage.haskell.org/package/directory
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.