Commit ddeb70b3 authored by Simon Peyton Jones's avatar Simon Peyton Jones

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.
parent 18e54762
......@@ -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 }
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment