Open amigalemming opened 5 months ago
Please be more specific. What exactly is the type signature of compareFilePath
? What is the implementation?
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)
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.
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.
On Sun, 4 Feb 2024, Julian Ospald wrote:
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.
I see there is more specification needed. I think about something like "compare (map toLower x) (map toLower y)", such that 'a' comes before 'B', whereas in case-sensitive ordering 'a' comes after 'B'. First ordering case-sensitive then filtering case-insensitive would not work in case of 'B', 'a', 'b'.
Additionally to
equalFilePath
we also needcompareFilePath
for sorting the contents of a directory and forPosix
we need a case-sensitive and a case-insensitive version for Linux and MacOS, respectively.