Skip to content

BangPatterns in PatternGuards don't work like docs would suggest

Summary and Steps to reproduce

The docs don't seem to say anything special about the interaction between bang patterns and pattern guards, so I wouldn't expect them to work any differently there. And yet:

let f  = case undefined of !_ -> () in f -- (a) fails (as expected)

let f | let !_ = undefined = ()     in f -- (b) fails (as expected)

let f | !_ <- undefined = ()        in f -- (c) succeeds...

Expected behavior

I would expect (c) to fail, in the same way as (a) and (b) do.

Alternatively, an explanation for how BangPatterns interact with PatternGuards could be added to the "Bang patterns" section in glasgow_exts.rst.

Environment

  • GHC version used: 8.6.5, 8.8.1
Edited by Jakob Brünker
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information