Skip to content

Commit

Permalink
Allow a vew pattern or bang pattern in a record pattern.
Browse files Browse the repository at this point in the history
e.g.
        data T = MkT { x,y :: Int }

        f (MkT { x = !v, y = negate -> w }) = v + w
  • Loading branch information
Takano Akio authored and Simon Peyton Jones committed Aug 16, 2012
1 parent de07bf2 commit 41c7342
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/parser/Parser.y.pp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,11 @@
| '..' { ([], True) }

fbind :: { HsRecField RdrName (LHsExpr RdrName) }
: qvar '=' exp { HsRecField $1 $3 False }
: qvar '=' texp { HsRecField $1 $3 False }
-- RHS is a 'texp', allowing view patterns (Trac #6038)
-- and, incidentaly, sections. Eg
-- f (R { x = show -> s }) = ...

| qvar { HsRecField $1 placeHolderPunRhs True }
-- In the punning case, use a place-holder
-- The renamer fills in the final value
Expand Down

0 comments on commit 41c7342

Please sign in to comment.