
Note that similar to the !Nothing example, a bang pattern surfaces the
error you'd expect
Prelude> :set -XBangPatterns
Prelude> let !1 = 2
*** Exception: <interactive>:2:5-10: Irrefutable pattern failed for pattern
1
So this exception is lurking about, but due to laziness and the equation's
irrelevance, it doesn't show unless you force it with strictness.
I think the real expectation mismatch here is that numbers are not bindable
symbols, so `let 1 = expr in 1` does not rebind 1 to be `expr` like a
beginner might think.
-- Dan Burton
On Thu, Feb 23, 2017 at 11:08 PM, Taeer Bar-Yam
I think the usefulness of numeric / string literals as pattern matches is as part of larger matches (as someone mentioned), not by itself. But since (I assume) these things are defined recursively, it makes sense just to add it as a base-level pattern match.
Furthermore, you would not want ``` main = let 1 = 2 in print "foo" ``` to error, since the pattern match is unused, and haskell is a lazy language. Really, though, we probably shouldn't be putting incomplete pattern matches in our code :P
--Taeer
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.