[commit: ghc] ghc-7.6: Allow a vew pattern or bang pattern in a record pattern. (038bec8)
Paolo Capriotti
p.capriotti at gmail.com
Mon Aug 20 14:28:42 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : ghc-7.6
http://hackage.haskell.org/trac/ghc/changeset/038bec8abc35114e15c2d870f860025b0d7e3baa
>---------------------------------------------------------------
commit 038bec8abc35114e15c2d870f860025b0d7e3baa
Author: Takano Akio <aljee at hyper.cx>
Date: Thu Aug 16 11:13:47 2012 +0100
Allow a vew pattern or bang pattern in a record pattern.
e.g.
data T = MkT { x,y :: Int }
f (MkT { x = !v, y = negate -> w }) = v + w
MERGED from commit 41c7342e7937dab55d082a0c5612f783e7eaa855
>---------------------------------------------------------------
compiler/parser/Parser.y.pp | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index 6213227..a4c08c1 100644
--- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -1751,7 +1751,11 @@ fbinds1 :: { ([HsRecField RdrName (LHsExpr RdrName)], Bool) }
| '..' { ([], 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
More information about the Cvs-ghc
mailing list