The reason is that the pattern match checker does not look into let bindings and their unfoldings, deliberately. Two reasons for that:
Efficiency. Recursively looking into big data structure unfoldings makes the checker slower, and the checker runs on every default invokation of GHC.
Abstraction barrier. The user extracted a let binding for a reason. One reason might be that the user wanted to prevent the checker from looking into a potentially big expression, or that the user actually wanted to keep the Nothing branch alive. Although there are perhaps better means to do so (considerAccessible). Your use case might be different.
I suggest you open an issue to discuss. This would be trivial to fix, but the potential for regressions is unclear.
This was just a minimal but contrived and useless example of what GHC (as of now) does not do.
I should maybe also post what “blew my mind” in regard to Python’s (Based Pyright’s) data flow analysis (also contrived and minimal some time ago:
state = A
while True:
match state:
case A:
state = B
case B:
case C: # here I got an "unreachable branch" warning
But what I actually wanted to express is that it really would be beneficial to at least take a cursory look at other languages and their current state before making statements about Haskell’s advantages. Because most of the arguments in this thread have been true 10 to 15 years ago.
Not you personally, you’re actually getting people back down to earth.
I’m sorry that the mentioning of ADTs triggered the response, it isn’t “more wrong” than many others in this (and other, related) thread, but it had just been too much to stay silent.
I don’t know what we should have done differently, but I feel like people who explicitly want to stretch themselves should not be bouncing off Haskell before they’ve even tried it.
It’s also interesting to see that he feels there are enough free learning resources around. From the inside, I’m not sure that’s the case, and I don’t know what I’d recommend to someone starting out.
It was a fairly light evaluation, I don’t know that I’d go so far as to say “bounced off”. (And I bounced off a few times myself, so don’t count them out yet!)
Their light-hearted assessment for Haskell seemed reasonable. The main objection was “Learning curve seems steep”, which isn’t wrong.
For this person, I think what might have swung the needle is an actively maintained, approachable web framework with an aura of success and most of all, Fun. They were seeking a relatively easy on-ramp and quick satisfaction.
The good-ish news is that someone motivated could step up and create one of those any time; it doesn’t require any major change in Haskell or its ecosystem (I think).
They correctly identified Yesod and IHP as the two main contenders, but neither of those quite hit the mark. (I think Yesod could be developed in that direction relatively economically, if someone wanted.)
I read the post and there really is nothing actionable about it for us.
They didn’t really try and it’s mostly just what the person thinks Haskell is like.
They end with
Haskell is the language I should learn when I work up the courage and patience.
Which seems fair. Because no matter how often I read in this forum that Haskell is easy to learn: no it isn’t for most people. So having time and focus is important.
Not really, if you look at it from a “Ship of Theseus” point of view. The ease of refactoring just lets you throw away your prototype board by board instead of wholesale.