-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
stdlib: add path libary #1384
Comments
It would probably be better to do this before/with #211 so there won't need to be any breaking changes. |
Possible API, though instead of using strings it might be worth considering using a record to store the path and having a path.parse to convert the string into a record for type safety that way the api should only error on parsing and not on actual manipulations, would also possibly allow for figuring out the seperator and supporting posixs and windows quickly as we cant get the system type from wasi easily so the best way to figure it out would be the seperator probably.
I might have missed some utility functions here but this would probably be a good start |
I'm 100% against using string types for file paths. They have caused so many miserable bugs in the compiler. |
so then the api might look something like this I guess
If a path type is used it would make sense to write this before #211 so 211 could accept the filePaths the downside to this is either you have to toString it for reading files or parse it for reading files but the type safety is worth it. |
You probably want to go look at ReasonNative's Fp library. They encode file paths interestingly. |
How should this library handle differences between POSIX/Windows paths? Some possible options I thought of:
Note: the second and third options aren't necessarily mutually exclusive, and both could be used simultaneously. |
I did some research and dit doesnt look to be possible to get the platform type from the operating systtem also that wouldnt make sense in a web enviroment. |
I think I'd lean towards enforcing POSIX-like paths. |
I think this would make sense would it be possible though maybe to add toWindows path and fromWindows path the conversion shouldn't be that hard realistically and that might allow more power to users when working on apps that are cross platform it would be nice if could handle both paths though as ideally there would probably be a |
Add a libary for working with file paths to help once #211
The text was updated successfully, but these errors were encountered: