r/haskellquestions • u/ellipticcode0 • Apr 02 '20
how to ignore function my my source code?
Hi,
does anyone know whether I can ignore a function in my source code in Haskell?
addOne::Int -> Int
addOne = (+1)How can make the compiler to ignore addOne in my source code without using comment syntax.
2
Upvotes
16
u/guaraqe Apr 02 '20
This seems to be a XY problem, what exactly do you want to do, that made you decide you need to ignore a function?
5
u/nicuveo Apr 02 '20
What do you mean, "ignore"?
If you mean: not expose it to the rest of your code base, then you could have your module explicitly list what it exports, and not include that function.
If you mean: not give you warnings about it being unused, you could deactivate warnings about unused local functions (search for ghc options pragma).
If you mean: entirely skip it, as if it were not here at all, as if it were not code, so that you can compile your file even if that function is all wrong... Well, that's what comments are for, really; if you don't want the compiler to see it as code, there aren't a lot of other options.
I suppose you could also use the CPP language extension and put it in between a
#if 0and#endif, but that would be quite overkill.