[GHC] #11634: Bang patterns bind... unexpectedly. Deserves loud warning
GHC
ghc-devs at haskell.org
Wed Feb 24 12:34:36 UTC 2016
#11634: Bang patterns bind... unexpectedly. Deserves loud warning
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.2.1
Component: Documentation | Version: 7.10.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Consider the following,
{{{#!hs
{-# 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,
{{{#!hs
hello (!(x:xs)) = ...
}}}
This strikes me as quite surprising, yet there is no mention of how `!` is
supposed to bind in the [[http://downloads.haskell.org/~ghc/master/users-
guide//glasgow_exts.html#ghc-flag--XBangPatterns|users guide]] nor the
[[https://prime.haskell.org/wiki/BangPatterns|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.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11634>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list