I noticed that Path
doesn't implement Eq
, but the isEq
function is commented out. This kind of thing would be helpful for testing, but it looks like this choice has been made on purpose. I'm just curious of the reasoning here, as I couldn't find out why
I'm not aware of any reason. Maybe it's just because they need to be canonicalised somehow so we can compare e.g. from OsStr or from a user provided Str. I don't see why we couldn't just auto derive it.
This is probably a @Richard Feldman question I think.
Yeah, would be great to enable eq, but iirc, you have to be careful. generic conanicalization of paths is tricky to get right. It might even require os calls to be correct (due to symlinks and the like). As such, it may not be possible in pure roc.
Yeah, I found the commit/PR where that got added. It looks like it was never in the codebase uncommented. It uses Str.isEqUtf8
which ins't currently in the builtins, so that'd be my guess as to why its commented out
Is a path a string or a list U8?
It looks like both. One variant is Str
, while the other two are bytes.
Also, for connivence, heres a link to the related code
Personally, I would suggest that for now you simply add a naiveEq method or something similar. Then make it just do Str.toUtf8
for the strings. Then use ==
on the underlying bytes.
It can obviously be expanded in various ways, but I think it is a good starter.
Last updated: Jul 05 2025 at 12:14 UTC