[GHC] #11634: Bang patterns bind... unexpectedly. Deserves loud warning

#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

#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 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I think it would be better to make bang bind more tightly so that it behaves the way you expect. We go to some trouble to make {{{ f !x y = e }}} mean {{{ f (!x) y = e }}} so bang binds pretty tightly there. This is a purely syntactic matter. Would anyone like to tackle it? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11634#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC