I know that I can cause a compile-time error by calling fail
from a splice, but is it possible to only generate a warning? In particular I would like it to be possible to turn this warning into an error when compiling with -Werror
.
Essentially what I'm trying to do is this:
todo :: Q Exp
todo = do
-- emit warning somehow
loc <- location
let message = ... -- generate message based on loc
[| error $(litE (stringL message)) |]
The idea is to use this instead of undefined
while coding, but make sure it doesn't sneak its way into production code by compiling with -Werror
.
myFunc x | isSimpleCase x = 42
| otherwise = $todo