Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Use Haskell for shell scripting. Parent comment
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)
There are no comments on this comment yet.
This can be done with the "bracket" function, which works roughly like a context manager in Python: