Hi,

after some debugging of a higher-level tool I found out that when I use
cpphs as a library and the `runCpphs` function that is to produce the
preprocessed output, when it comes across the #error directive it will
terminate my program.

This is because handling #error is implemented with Haskell's `error`.

I find that slightly unfortunate since it means I cannot distinguish
betwen an #error written in the input file and a programming error
inside cpphs.

@Malcolm, would you mind a change towards throwing an exception that is
different from error so that it can be easily caught, or even better, a
change from

    runCpphs :: ... -> IO String

to

    runCpphs :: ... -> IO (Either String String)

or similar?

If an exception based interface is kept, it would be nice to add some
haddock to `runCpphs`; not knowing about the existence of #error, it is
easy to assume that the IO is only used for accessing the FilePath
passed in.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to