hoppy-generator-0.8.0: C++ FFI generator - Code generator
Safe HaskellSafe-Inferred
LanguageHaskell2010

Foreign.Hoppy.Generator.Util

Description

Miscellaneous utilities that may be useful in Hoppy generators.

Synopsis

String utilities

splitIntoWords :: String -> [String] Source #

Splits a C++ identifier string into multiple words, doing smart inspection of the case convention of the string. This supports snake_case and CONSTANT_CASE, and recognition of camelCase, including when acronyms are uppercased ("HTMLElement" gives ["HTML", "Element"]). Numbers are treated as their own words, and non-alphanumeric characters are treated as word separators and dropped.

File utilities

withTempFile :: String -> Bool -> (FilePath -> Handle -> IO (Bool, a)) -> IO a Source #

Creates a temporary file whose name is based on the given template string, and runs the given function with the path to the file. The file is deleted when the function completes, if the boolean that the function returns (or, in case of an exception, the boolean that was passed directly to withTempFile) is true.

withTempDirectory :: String -> Bool -> (FilePath -> IO (Bool, a)) -> IO a Source #

Creates a temporary directory whose name is based on the given template string, and runs the given function with the directory's path. The directory is deleted when the function completes, if the boolean that the function returns (or, in case of an exception, the boolean that was passed directly to withTempDirectory) is true.