
On Wed, Feb 11, 2015 at 12:11 AM, Joel Neely
So it would appear that the advice (per Kim-Ee) to add an "otherwise" as a third guard allows me to satisfy the compiler while documenting to the human reader that the definition is really complete without it.
Thanks for the citation! But if you look at lots of haskell code, I don't think there's One Best Style on how to write haskell. E.g. I hardly ever use guards and I'm far from being alone. For the code in question I'd probably have ended up with an if expression, although I do see the structural elegance that guards bring here. Another e.g. some will argue that the "right" approach is to collapse to 2 guards with the otherwise in the 2nd one. So the reader is expected to infer in a snap that if n is not < 10 then obviously it's >= 10. A "strong opinions, weakly held" strategy might work best. Be bold, make choices, trust in the warm diversity of the haskell universe. Don Stewart has a nice list of coding styles here: http://stackoverflow.com/a/6399082 -- Kim-Ee