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

Lexigraphic ordering #225

Open
amigalemming opened this issue Feb 4, 2024 · 5 comments
Open

Lexigraphic ordering #225

amigalemming opened this issue Feb 4, 2024 · 5 comments

Comments

@amigalemming
Copy link

Additionally to equalFilePath we also need compareFilePath for sorting the contents of a directory and for Posix we need a case-sensitive and a case-insensitive version for Linux and MacOS, respectively.

@hasufell
Copy link
Member

hasufell commented Feb 4, 2024

Please be more specific. What exactly is the type signature of compareFilePath? What is the implementation?

@amigalemming
Copy link
Author

I think it should be:

compareFilePath :: OsPath -> OsPath -> Ordering

It should at least be compatible with equalFilePath, that is:

property $ \x y -> equalFilePath x y == (compareFilePath x y = EQ)

@hasufell
Copy link
Member

hasufell commented Feb 4, 2024

for sorting the contents of a directory

Why not just use compare (which is bytestring comparison)? That will sort it. Afterwards you can still apply equalFilePath if you need more precise distinction.

@hasufell
Copy link
Member

hasufell commented Feb 4, 2024

Afterwards you can still apply equalFilePath if you need more precise distinction.

In fact, given your use case of sorting directory contents, this is entirely obsolete, since you cannot have the same file twice. So compare is enough.

@amigalemming
Copy link
Author

amigalemming commented Feb 4, 2024 via email

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