Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Utility functions that may be ultimately moved to some library.
Documentation
withFileOrHandle :: FilePath -> IOMode -> Handle -> (Handle -> IO r) -> IO r Source #
Generic function for opening file if the filename is not empty nor "-", or using given handle otherwise (probably stdout, stderr, or stdin). TODO: Should it become utility function?
withFileOrDefaultHandle :: FilePath -> IOMode -> (Handle -> IO r) -> IO r Source #
Generic function for choosing either file with given name or stdinstdout as inputoutput. It accepts the function that takes the corresponding handle. Stdin/stdout is selected by "-".