Bang patterns bind... unexpectedly. Deserves loud warning
Consider the following,
{-# LANGUAGE BangPatterns #-}
hello :: [Int] -> ()
hello (!x:xs) = ...
To me it seems like the bang pattern should be applied to x
; but it's not! In fact, this program is equivalent to,
hello (!(x:xs)) = ...
This strikes me as quite surprising, yet there is no mention of how !
is supposed to bind in the users guide nor the Haskell Prime proposal.
This behavior is slightly less surprising if you consider that the bang pattern !Just x
is equivalent to !(Just x)
(although this also strikes me as a bit unfortunate, although it is likely too late to do much about this).
In sum: We need to document the current syntactic binding properties of !
in the users guide.
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Documentation |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |