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.
Just add path-extra
to stack.yaml
file.
extra-deps:
- git: https://github.com/d12frosted/path-extra
commit: 47d59985c7ad939598d35cbe471fe49b930b3484