Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/ddeb70b333a94990dbdf432303cb1f10f2d3062d

>---------------------------------------------------------------

commit ddeb70b333a94990dbdf432303cb1f10f2d3062d
Author: Simon Peyton Jones <[email protected]>
Date:   Fri Dec 23 16:01:51 2011 +0000

    Fix the behaviour of the unit unboxed tuple (# #)
    
    See Trac #5720: make the unit unboxed tuple (# #) behave uniformly
    with the unit boxed tuple ()
    
    This is actually a change in behaviour, but in a very dark corner,
    so I don't think this is going to hurt anyone, and the current
    behaviour is deeply strange.

>---------------------------------------------------------------

 compiler/parser/Parser.y.pp     |   23 +++++++++++++++--------
 compiler/prelude/TysWiredIn.lhs |    8 +++++++-
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index 855a428..861c15a 100644
--- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -35,7 +35,7 @@ import RdrName
 import TcEvidence       ( emptyTcEvBinds )
 import TysPrim          ( liftedTypeKindTyConName, eqPrimTyCon )
 import TysWiredIn       ( unitTyCon, unitDataCon, tupleTyCon, tupleCon, 
nilDataCon,
-                          unboxedSingletonTyCon, unboxedSingletonDataCon,
+                          unboxedUnitTyCon, unboxedUnitDataCon,
                           listTyCon_RDR, parrTyCon_RDR, consDataCon_RDR, 
eqTyCon_RDR )
 import Type             ( funTyCon )
 import ForeignCall      ( Safety(..), CExportSpec(..), CLabelString,
@@ -1779,7 +1779,7 @@ con_list : con                  { L1 [$1] }
 sysdcon :: { Located DataCon }  -- Wired in data constructors
         : '(' ')'               { LL unitDataCon }
         | '(' commas ')'        { LL $ tupleCon BoxedTuple ($2 + 1) }
-        | '(#' '#)'             { LL $ unboxedSingletonDataCon }
+        | '(#' '#)'             { LL $ unboxedUnitDataCon }
         | '(#' commas '#)'      { LL $ tupleCon UnboxedTuple ($2 + 1) }
         | '[' ']'               { LL nilDataCon }
 
@@ -1791,24 +1791,31 @@ qconop :: { Located RdrName }
         : qconsym               { $1 }
         | '`' qconid '`'        { LL (unLoc $2) }
 
------------------------------------------------------------------------------
+----------------------------------------------------------------------------
 -- Type constructors
 
-gtycon  :: { Located RdrName }  -- A "general" qualified tycon
-        : oqtycon                       { $1 }
+
+-- See Note [Unit tuples] in HsTypes for the distinction 
+-- between gtycon and ntgtycon
+gtycon :: { Located RdrName }  -- A "general" qualified tycon, including unit 
tuples
+        : ntgtycon                      { $1 }
         | '(' ')'                       { LL $ getRdrName unitTyCon }
+        | '(#' '#)'                     { LL $ getRdrName unboxedUnitTyCon }
+
+ntgtycon :: { Located RdrName }  -- A "general" qualified tycon, excluding 
unit tuples
+        : oqtycon                       { $1 }
         | '(' commas ')'                { LL $ getRdrName (tupleTyCon 
BoxedTuple ($2 + 1)) }
-        | '(#' '#)'                     { LL $ getRdrName 
unboxedSingletonTyCon }
         | '(#' commas '#)'              { LL $ getRdrName (tupleTyCon 
UnboxedTuple ($2 + 1)) }
         | '(' '->' ')'                  { LL $ getRdrName funTyCon }
         | '[' ']'                       { LL $ listTyCon_RDR }
         | '[:' ':]'                     { LL $ parrTyCon_RDR }
         | '(' '~#' ')'                  { LL $ getRdrName eqPrimTyCon }
 
-oqtycon :: { Located RdrName }  -- An "ordinary" qualified tycon
+oqtycon :: { Located RdrName }  -- An "ordinary" qualified tycon;
+                                -- These can appear in export lists
         : qtycon                        { $1 }
         | '(' qtyconsym ')'             { LL (unLoc $2) }
-        | '(' '~' ')'                   { LL $ eqTyCon_RDR } -- In here rather 
than gtycon because I want to write it in the GHC.Types export list
+        | '(' '~' ')'                   { LL $ eqTyCon_RDR }
 
 qtyconop :: { Located RdrName } -- Qualified or unqualified
         : qtyconsym                     { $1 }
diff --git a/compiler/prelude/TysWiredIn.lhs b/compiler/prelude/TysWiredIn.lhs
index c6991e1..ec760d7 100644
--- a/compiler/prelude/TysWiredIn.lhs
+++ b/compiler/prelude/TysWiredIn.lhs
@@ -56,7 +56,8 @@ module TysWiredIn (
        mkTupleTy, mkBoxedTupleTy,
        tupleTyCon, tupleCon, 
        unitTyCon, unitDataCon, unitDataConId, pairTyCon, 
-       unboxedSingletonTyCon, unboxedSingletonDataCon,
+       unboxedUnitTyCon, unboxedUnitDataCon, 
+        unboxedSingletonTyCon, unboxedSingletonDataCon,
        unboxedPairTyCon, unboxedPairDataCon,
 
         -- * Unit
@@ -367,6 +368,11 @@ unitDataConId = dataConWorkId unitDataCon
 pairTyCon :: TyCon
 pairTyCon = tupleTyCon BoxedTuple 2
 
+unboxedUnitTyCon :: TyCon
+unboxedUnitTyCon   = tupleTyCon UnboxedTuple 0
+unboxedUnitDataCon :: DataCon
+unboxedUnitDataCon = tupleCon   UnboxedTuple 0
+
 unboxedSingletonTyCon :: TyCon
 unboxedSingletonTyCon   = tupleTyCon UnboxedTuple 1
 unboxedSingletonDataCon :: DataCon



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to