path-extra
Path helpers for my personal projects. Currently exposes only one module -
Path.Parse
. Please refer to it for list of all exposed functions. But let me
show you two functions which I use the most.
位> :t parseFilePath
parseFilePath
:: (MonadThrow m, MonadIO m) => Text -> m (Path Abs File)
位> parseFilePath "$XDG_CONFIG_HOME/.gitignore"
"/Users/d12frosted/.environment/.gitignore"
位> :t parseDirPath
parseDirPath
:: (MonadThrow m, MonadIO m) => Text -> m (Path Abs Dir)
位> parseDirPath "$XDG_CONFIG_HOME"
"/Users/d12frosted/.environment/"
位> parseDirPath "$FALSE"
*** Exception: Could not find value of $FALSE in environment.
位> parseDirPath "~/Developer"
"/Users/d12frosted/Developer/"
Both of them are great for parsing path from user input. Because they expand
environment variables and ~/
.
At some extent this library was created after CanonicalPath was deprecated. Thanks to Chris Done now we have a better type for path.
stack
Using with Just add path-extra
to stack.yaml
file.
extra-deps:
- git: https://github.com/d12frosted/path-extra
commit: 47d59985c7ad939598d35cbe471fe49b930b3484