json-to-type-4.0.0: Automatic type declaration for JSON input data
Safe HaskellSafe-Inferred
LanguageHaskell2010

JsonToType.Util

Description

Utility functions that may be ultimately moved to some library.

Synopsis

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 "-".