Skip to content

Additional OsPath/OsString implementation for Path#198

Open
clintonmead wants to merge 2 commits into
commercialhaskell:masterfrom
clintonmead:master
Open

Additional OsPath/OsString implementation for Path#198
clintonmead wants to merge 2 commits into
commercialhaskell:masterfrom
clintonmead:master

Conversation

@clintonmead

@clintonmead clintonmead commented Jun 19, 2026

Copy link
Copy Markdown

OsPath.Posix and OsPath.Windows have in their APIs references to PosixPath and WindowsPath respectively.

Other libraries tend to use OsPath, which is just a type alias for OsString, but OsString is not a type alias for PosixPath/WindowsPath, it's a newtype wrapper. Hence interacting with libraries which use OsPath/OsString as their underlying type is a bit of a pain.

So this PR adds an OsPath.OsString module, much like OsPath.Posix and OsPath.Windows which already exist.

The nice thing about OsPath.OsString is that code written against it works on both Posix and Windows, whereas code written against OsPath.Posix would need to have it's module imports changed to work on Windows and via versa for code written against OsPath.Windows. Whilst this is relatively trivial it does mean that one can't make platform independent code with this library currently. But with OsPath.OsString is actually multiplatform unlike the alternatives and should be able to be run on Windows and Posix without code changes.

I haven't really fleshed out test cases but I have got this working on an internal project. If you're happy with the general direction of the PR I'm happy to take the time to add the test cases as you think appropriate.

(Oh I just noticed this basically implements #197)

This exposes the library interface under the type OsString, which is actually a platform independent interface, instead of exposing WindowsString and PosixString directly in the interface
This is so we can we can produce platform strings when required for functions in this library in the same way for all modules in this library, easing migration between the modules
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