|
|
|
|
|
by danidiaz
4151 days ago
|
|
> What's the idiom for chdir'ing to a subdirectory such that you pop back out again when you're done This can be done with the "bracket" function, which works roughly like a context manager in Python: import Control.Exception
import System.Directory
withDirectory :: FilePath -> IO a -> IO a
withDirectory path action = bracket (getCurrentDirectory <* setCurrentDirectory path)
setCurrentDirectory
(const action)
|
|