
20 Apr
2024
20 Apr
'24
1:05 a.m.
So your code is essentially pattern matching on a list to decide ...,
then pattern matching on the Bool to split between two cases, then pattern matching on the list again. If you had kept the result of the first pattern match there would be no need for the latter two.
Essentially the problem is "boolean blindness" ...
This style of coding is generally more readable, maintainable, and less
error-prone. ...
+1 to Ben's wise advice. +1 to "more readable". Haskell is a 'functional language' does not mean everything everywhere has to be expressed only through functions. Perhaps we should promote 'Algebraic data types' (yay mathy!) and 'pattern matching' right up front on the 'Features' section of Haskell.org? AntC