Errors with Template Haskell

Hi, In Template Haskell, what is the proper way of signalling an error ? For example, you are generating code and you detect that a given parameter does not fulfill a precondition (e.g., String is empty), and you want to abort compilation with a descriptive error message. Thanks, Jose -- Jose Antonio Lopes Ganeti Engineering Google Germany GmbH Dienerstr. 12, 80331, München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores Steuernummer: 48/725/00206 Umsatzsteueridentifikationsnummer: DE813741370

The Template Haskell quotation monad (Q) has proper support for fail:
module A where
import Language.Haskell.TH
foo :: Q Exp
foo = fail "Custom compile error!"
and
module B where
import A
main :: IO ()
main = print $foo
gives
B.hs:6:14:
Custom compile error!
In the first argument of `print', namely `$foo'
In the expression: print ($foo)
In an equation for `main': main = print ($foo)
-E
On Fri, Aug 9, 2013 at 9:48 AM, Jose A. Lopes
Hi,
In Template Haskell, what is the proper way of signalling an error ?
For example, you are generating code and you detect that a given parameter does not fulfill a precondition (e.g., String is empty), and you want to abort compilation with a descriptive error message.
Thanks, Jose
-- Jose Antonio Lopes Ganeti Engineering Google Germany GmbH Dienerstr. 12, 80331, München
Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores Steuernummer: 48/725/00206 Umsatzsteueridentifikationsnummer: DE813741370
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thank you! -- Jose Antonio Lopes Ganeti Engineering Google Germany GmbH Dienerstr. 12, 80331, München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores Steuernummer: 48/725/00206 Umsatzsteueridentifikationsnummer: DE813741370
participants (2)
-
Edsko de Vries
-
Jose A. Lopes