
On Sunday 13 January 2013, 21:27:44, Petr P wrote:
I wonder:
(1) Is there a way how to disable the warning? As the main aim of the library is speed, I believe -O2 is appropriate here. And since the code is quite short, I'm quite sure the increased compile time won't be noticeable.
(2) Why does cabal complain about it at the first place? I found a reference saying the warning is adequate: https://github.com/haskell/cabal/issues/808 but not saying why. Maybe for complex programs -O2 prolongs compile time too much, but libraries are usually compiled once and used many times, so using -O2 for them seems reasonable in many cases.
Sometimes compiling with -O2 instead of just -O takes significantly longer. Not always is the produced result faster (often, the results are identical). So if the code produced with -O performs equally to that produced with -O2, and the -O2 compilation takes significantly longer, choosing -O2 imposes a cost for no benefit. That's, I think, why the warning is considered adequate. You can specify -O2 on a per-module basis with an {-# OPTIONS_GHC -O2 #-} pragma where it matters, then cabal won't complain. Or, if you're too lazy to check the consequences of -O2 vs. -O for each module (like I usually am, if there are more than a handful), just verify that -O2 does indeed make a significant difference for the speed of the result in some places without increasing compile time unduly, and henceforth ignore the warning if it does. (Re-test every couple of compiler versions.) After some time, you tend to not even notice it anymore ;) Cheers, Daniel