Skip to content
  • Matthew Pickering's avatar
    Fix push_bang_into_newtype when the pattern match has no arguments · 062f1123
    Matthew Pickering authored and Ben Gamari's avatar Ben Gamari committed
    Correct behaviour of push_bang_into_newtype when the pattern match has
    no arguments. A user can write
    
    ```
    newtype T = T Int
    
    f :: T -> ()
    f !(T {}) = ()
    ```
    in which case we have to push the bang inwards through the newtype in
    order to achieve the desired strictness properties. This patch fixes
    this special case where the pattern match has no arguments to push the
    bang onto. We now make up a wildcard pattern which is wrapped in the
    bang pattern.
    
    ```
    f (T !_) = ()
    ```
    
    Reviewers: simonpj, austin, bgamari
    
    Reviewed By: simonpj
    
    Subscribers: simonpj, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3057
    062f1123