haskell - Compiler switch to turn debugging messages on/off? -


ok, here's simple question. i've written function debug :: string -> io (). i'd set things when compile program 1 way, function writes standard error, , if compile program way, function becomes no-op. there easy compile-time switch that? or have implement myself?

i don't think involving trace right approach solve problem.

instead, use preprocessor disable/enable debug messages. put following in separate file:

{-# language cpp #-} import system.io  debug :: string -> io () debug message = #ifdef debug   hputstrln stderr message #else   return () #endif 

the {-# language cpp #-} line enables c preprocessor current file. can compile file with/without debugging using ghc -ddebug or ghc.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -