[Haskell-cafe] ghc should be able to deduce correct use of partial functions and not give a warning in such cases

Anthony Clayden anthony.d.clayden at gmail.com
Sat Apr 20 05:05:42 UTC 2024


>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20240420/17f1e7ab/attachment.html>


More information about the Haskell-Cafe mailing list