summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-07-12 22:08:10 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-22 20:21:48 -0400
commitcfa89149b55837f822ba619b797781813fdcdabc (patch)
tree932b9af9f50b88b137b6faf42050e3e2445d252c
parentff1b7710c9975a3cc1025cb5b9d29197a5f1a98a (diff)
downloadhaskell-cfa89149b55837f822ba619b797781813fdcdabc.tar.gz
Define type Void# = (# #) (#18441)
There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts.
-rw-r--r--compiler/GHC/Builtin/Names.hs3
-rw-r--r--compiler/GHC/Builtin/Types.hs4
-rw-r--r--compiler/GHC/Builtin/Types/Prim.hs11
-rw-r--r--compiler/GHC/Builtin/primops.txt.pp2
-rw-r--r--compiler/GHC/Core/Opt/Specialise.hs4
-rw-r--r--compiler/GHC/Core/Opt/WorkWrap/Utils.hs5
-rw-r--r--compiler/GHC/CoreToByteCode.hs9
-rw-r--r--compiler/GHC/HsToCore/Utils.hs5
-rw-r--r--compiler/GHC/Tc/TyCl/Build.hs7
-rw-r--r--compiler/GHC/Tc/TyCl/PatSyn.hs6
-rw-r--r--compiler/GHC/Types/Id/Make.hs17
-rw-r--r--docs/users_guide/8.12.1-notes.rst3
-rwxr-xr-xlibraries/base/GHC/Exts.hs1
-rw-r--r--libraries/base/tests/isValidNatural.hs4
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/BigNat.hs98
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/BigNat/Check.hs12
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Integer.hs2
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Primitives.hs10
-rw-r--r--libraries/ghc-prim/GHC/Prim/Exception.hs6
-rw-r--r--libraries/ghc-prim/GHC/Prim/Panic.hs4
-rw-r--r--libraries/ghc-prim/GHC/Types.hs4
-rw-r--r--testsuite/tests/codeGen/should_compile/T12115.hs2
-rw-r--r--testsuite/tests/printer/T18052a.stderr2
-rw-r--r--testsuite/tests/simplCore/should_compile/T13143.stderr10
-rw-r--r--testsuite/tests/unboxedsums/ffi1.hs2
-rw-r--r--utils/genprimopcode/Main.hs2
26 files changed, 119 insertions, 116 deletions
diff --git a/compiler/GHC/Builtin/Names.hs b/compiler/GHC/Builtin/Names.hs
index b9ef184923..2130448e89 100644
--- a/compiler/GHC/Builtin/Names.hs
+++ b/compiler/GHC/Builtin/Names.hs
@@ -1802,7 +1802,7 @@ statePrimTyConKey, stableNamePrimTyConKey, stableNameTyConKey,
liftedConKey, unliftedConKey, anyBoxConKey, kindConKey, boxityConKey,
typeConKey, threadIdPrimTyConKey, bcoPrimTyConKey, ptrTyConKey,
funPtrTyConKey, tVarPrimTyConKey, eqPrimTyConKey,
- eqReprPrimTyConKey, eqPhantPrimTyConKey, voidPrimTyConKey,
+ eqReprPrimTyConKey, eqPhantPrimTyConKey,
compactPrimTyConKey :: Unique
statePrimTyConKey = mkPreludeTyConUnique 50
stableNamePrimTyConKey = mkPreludeTyConUnique 51
@@ -1812,7 +1812,6 @@ eqReprPrimTyConKey = mkPreludeTyConUnique 54
eqPhantPrimTyConKey = mkPreludeTyConUnique 55
mutVarPrimTyConKey = mkPreludeTyConUnique 56
ioTyConKey = mkPreludeTyConUnique 57
-voidPrimTyConKey = mkPreludeTyConUnique 58
wordPrimTyConKey = mkPreludeTyConUnique 59
wordTyConKey = mkPreludeTyConUnique 60
word8PrimTyConKey = mkPreludeTyConUnique 61
diff --git a/compiler/GHC/Builtin/Types.hs b/compiler/GHC/Builtin/Types.hs
index 86b8879c60..ce506000ac 100644
--- a/compiler/GHC/Builtin/Types.hs
+++ b/compiler/GHC/Builtin/Types.hs
@@ -75,6 +75,7 @@ module GHC.Builtin.Types (
promotedTupleDataCon,
unitTyCon, unitDataCon, unitDataConId, unitTy, unitTyConKey,
pairTyCon,
+ unboxedUnitTy,
unboxedUnitTyCon, unboxedUnitDataCon,
unboxedTupleKind, unboxedSumKind,
@@ -1053,6 +1054,9 @@ unitDataConId = dataConWorkId unitDataCon
pairTyCon :: TyCon
pairTyCon = tupleTyCon Boxed 2
+unboxedUnitTy :: Type
+unboxedUnitTy = mkTyConApp unboxedUnitTyCon []
+
unboxedUnitTyCon :: TyCon
unboxedUnitTyCon = tupleTyCon Unboxed 0
diff --git a/compiler/GHC/Builtin/Types/Prim.hs b/compiler/GHC/Builtin/Types/Prim.hs
index 13f08739d0..511af6f217 100644
--- a/compiler/GHC/Builtin/Types/Prim.hs
+++ b/compiler/GHC/Builtin/Types/Prim.hs
@@ -45,7 +45,6 @@ module GHC.Builtin.Types.Prim(
floatPrimTyCon, floatPrimTy, floatPrimTyConName,
doublePrimTyCon, doublePrimTy, doublePrimTyConName,
- voidPrimTyCon, voidPrimTy,
statePrimTyCon, mkStatePrimTy,
realWorldTyCon, realWorldTy, realWorldStatePrimTy,
@@ -180,7 +179,6 @@ exposedPrimTyCons
, stableNamePrimTyCon
, compactPrimTyCon
, statePrimTyCon
- , voidPrimTyCon
, proxyPrimTyCon
, threadIdPrimTyCon
, wordPrimTyCon
@@ -209,7 +207,7 @@ mkBuiltInPrimTc fs unique tycon
BuiltInSyntax
-charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName, voidPrimTyConName :: Name
+charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName :: Name
charPrimTyConName = mkPrimTc (fsLit "Char#") charPrimTyConKey charPrimTyCon
intPrimTyConName = mkPrimTc (fsLit "Int#") intPrimTyConKey intPrimTyCon
int8PrimTyConName = mkPrimTc (fsLit "Int8#") int8PrimTyConKey int8PrimTyCon
@@ -225,7 +223,6 @@ addrPrimTyConName = mkPrimTc (fsLit "Addr#") addrPrimTyConKey addrPr
floatPrimTyConName = mkPrimTc (fsLit "Float#") floatPrimTyConKey floatPrimTyCon
doublePrimTyConName = mkPrimTc (fsLit "Double#") doublePrimTyConKey doublePrimTyCon
statePrimTyConName = mkPrimTc (fsLit "State#") statePrimTyConKey statePrimTyCon
-voidPrimTyConName = mkPrimTc (fsLit "Void#") voidPrimTyConKey voidPrimTyCon
proxyPrimTyConName = mkPrimTc (fsLit "Proxy#") proxyPrimTyConKey proxyPrimTyCon
eqPrimTyConName = mkPrimTc (fsLit "~#") eqPrimTyConKey eqPrimTyCon
eqReprPrimTyConName = mkBuiltInPrimTc (fsLit "~R#") eqReprPrimTyConKey eqReprPrimTyCon
@@ -897,12 +894,6 @@ realWorldStatePrimTy = mkStatePrimTy realWorldTy -- State# RealWorld
-- so they are defined in \tr{GHC.Builtin.Types}, not here.
-voidPrimTy :: Type
-voidPrimTy = TyConApp voidPrimTyCon []
-
-voidPrimTyCon :: TyCon
-voidPrimTyCon = pcPrimTyCon voidPrimTyConName [] VoidRep
-
mkProxyPrimTy :: Type -> Type -> Type
mkProxyPrimTy k ty = TyConApp proxyPrimTyCon [k, ty]
diff --git a/compiler/GHC/Builtin/primops.txt.pp b/compiler/GHC/Builtin/primops.txt.pp
index 261d02aa67..98a8daccc0 100644
--- a/compiler/GHC/Builtin/primops.txt.pp
+++ b/compiler/GHC/Builtin/primops.txt.pp
@@ -3355,8 +3355,6 @@ section "Misc"
{These aren't nearly as wired in as Etc...}
------------------------------------------------------------------------
-primtype Void#
-
primop GetCCSOfOp "getCCSOf#" GenPrimOp
a -> State# s -> (# State# s, Addr# #)
diff --git a/compiler/GHC/Core/Opt/Specialise.hs b/compiler/GHC/Core/Opt/Specialise.hs
index 173dcdf2c7..935ba04bb5 100644
--- a/compiler/GHC/Core/Opt/Specialise.hs
+++ b/compiler/GHC/Core/Opt/Specialise.hs
@@ -39,7 +39,7 @@ import GHC.Core.Opt.Arity ( etaExpandToJoinPointRule )
import GHC.Types.Unique.Supply
import GHC.Types.Name
import GHC.Types.Id.Make ( voidArgId, voidPrimId )
-import GHC.Builtin.Types.Prim ( voidPrimTy )
+import GHC.Builtin.Types ( unboxedUnitTy )
import GHC.Data.Maybe ( mapMaybe, maybeToList, isJust )
import GHC.Utils.Monad ( foldlM )
import GHC.Types.Basic
@@ -1427,7 +1427,7 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs
(spec_bndrs, spec_rhs, spec_fn_ty)
| add_void_arg = ( voidPrimId : spec_bndrs1
, Lam voidArgId spec_rhs1
- , mkVisFunTyMany voidPrimTy spec_fn_ty1)
+ , mkVisFunTyMany unboxedUnitTy spec_fn_ty1)
| otherwise = (spec_bndrs1, spec_rhs1, spec_fn_ty1)
join_arity_decr = length rule_lhs_args - length spec_bndrs
diff --git a/compiler/GHC/Core/Opt/WorkWrap/Utils.hs b/compiler/GHC/Core/Opt/WorkWrap/Utils.hs
index 1885de98f2..2ccc743047 100644
--- a/compiler/GHC/Core/Opt/WorkWrap/Utils.hs
+++ b/compiler/GHC/Core/Opt/WorkWrap/Utils.hs
@@ -28,8 +28,7 @@ import GHC.Types.Cpr
import GHC.Core.Make ( mkAbsentErrorApp, mkCoreUbxTup
, mkCoreApp, mkCoreLet )
import GHC.Types.Id.Make ( voidArgId, voidPrimId )
-import GHC.Builtin.Types ( tupleDataCon )
-import GHC.Builtin.Types.Prim ( voidPrimTy )
+import GHC.Builtin.Types ( tupleDataCon, unboxedUnitTy )
import GHC.Types.Literal ( absentLiteralOf, rubbishLit )
import GHC.Types.Var.Env ( mkInScopeSet )
import GHC.Types.Var.Set ( VarSet )
@@ -1256,7 +1255,7 @@ mk_absent_let dflags fam_envs arg
| Just tc <- tyConAppTyCon_maybe nty
, Just lit <- absentLiteralOf tc
= Just (Let (NonRec arg (Lit lit `mkCast` mkSymCo co)))
- | nty `eqType` voidPrimTy
+ | nty `eqType` unboxedUnitTy
= Just (Let (NonRec arg (Var voidPrimId `mkCast` mkSymCo co)))
| otherwise
= WARN( True, text "No absent value for" <+> ppr arg_ty )
diff --git a/compiler/GHC/CoreToByteCode.hs b/compiler/GHC/CoreToByteCode.hs
index 73acd2a19f..40866f7f8b 100644
--- a/compiler/GHC/CoreToByteCode.hs
+++ b/compiler/GHC/CoreToByteCode.hs
@@ -43,6 +43,7 @@ import GHC.Core.DataCon
import GHC.Core.TyCon
import GHC.Utils.Misc
import GHC.Types.Var.Set
+import GHC.Builtin.Types ( unboxedUnitTy )
import GHC.Builtin.Types.Prim
import GHC.Core.TyCo.Ppr ( pprType )
import GHC.Utils.Error
@@ -673,7 +674,7 @@ schemeE d s p (AnnCase scrut bndr _ alt@[(DEFAULT, [], _)])
| isUnboxedTupleType (idType bndr)
, Just ty <- case typePrimRep (idType bndr) of
[_] -> Just (unwrapType (idType bndr))
- [] -> Just voidPrimTy
+ [] -> Just unboxedUnitTy
_ -> Nothing
-- handles any pattern with a single non-void binder; in particular I/O
-- monad returns (# RealWorld#, a #)
@@ -708,7 +709,7 @@ protectNNLJoinPointBind x rhs@(fvs, _)
protectNNLJoinPointId :: Id -> Id
protectNNLJoinPointId x
= ASSERT( isNNLJoinPoint x )
- updateIdTypeButNotMult (voidPrimTy `mkVisFunTyMany`) x
+ updateIdTypeButNotMult (unboxedUnitTy `mkVisFunTyMany`) x
{-
Ticked Expressions
@@ -743,8 +744,8 @@ isUnliftedType check in the AnnVar case of schemeE.) Here is the strategy:
1. Detect NNLJPs. This is done in isNNLJoinPoint.
-2. When binding an NNLJP, add a `\ (_ :: Void#) ->` to its RHS, and modify the
- type to tack on a `Void# ->`. (Void# is written voidPrimTy within GHC.)
+2. When binding an NNLJP, add a `\ (_ :: (# #)) ->` to its RHS, and modify the
+ type to tack on a `(# #) ->`.
Note that functions are never levity-polymorphic, so this transformation
changes an NNLJP to a non-levity-polymorphic join point. This is done
in protectNNLJoinPointBind, called from the AnnLet case of schemeE.
diff --git a/compiler/GHC/HsToCore/Utils.hs b/compiler/GHC/HsToCore/Utils.hs
index ae2e071f7b..ac75e078c4 100644
--- a/compiler/GHC/HsToCore/Utils.hs
+++ b/compiler/GHC/HsToCore/Utils.hs
@@ -67,7 +67,6 @@ import GHC.Core.DataCon
import GHC.Core.PatSyn
import GHC.Core.Type
import GHC.Core.Coercion
-import GHC.Builtin.Types.Prim
import GHC.Builtin.Types
import GHC.Types.Basic
import GHC.Core.ConLike
@@ -853,8 +852,8 @@ mkFailurePair :: CoreExpr -- Result type of the whole case expression
CoreExpr) -- Fail variable applied to realWorld#
-- See Note [Failure thunks and CPR]
mkFailurePair expr
- = do { fail_fun_var <- newFailLocalDs Many (voidPrimTy `mkVisFunTyMany` ty)
- ; fail_fun_arg <- newSysLocalDs Many voidPrimTy
+ = do { fail_fun_var <- newFailLocalDs Many (unboxedUnitTy `mkVisFunTyMany` ty)
+ ; fail_fun_arg <- newSysLocalDs Many unboxedUnitTy
; let real_arg = setOneShotLambda fail_fun_arg
; return (NonRec fail_fun_var (Lam real_arg expr),
App (Var fail_fun_var) (Var voidPrimId)) }
diff --git a/compiler/GHC/Tc/TyCl/Build.hs b/compiler/GHC/Tc/TyCl/Build.hs
index 5361ff0160..da17266c45 100644
--- a/compiler/GHC/Tc/TyCl/Build.hs
+++ b/compiler/GHC/Tc/TyCl/Build.hs
@@ -21,8 +21,7 @@ import GHC.Prelude
import GHC.Iface.Env
import GHC.Core.FamInstEnv( FamInstEnvs, mkNewTypeCoAxiom )
-import GHC.Builtin.Types( isCTupleTyConName )
-import GHC.Builtin.Types.Prim ( voidPrimTy )
+import GHC.Builtin.Types( isCTupleTyConName, unboxedUnitTy )
import GHC.Core.DataCon
import GHC.Core.PatSyn
import GHC.Types.Var
@@ -209,11 +208,11 @@ buildPatSyn src_name declared_infix matcher@(matcher_id,_) builder
subst = zipTvSubst (univ_tvs1 ++ ex_tvs1)
(mkTyVarTys (binderVars (univ_tvs ++ ex_tvs)))
- -- For a nullary pattern synonym we add a single void argument to the
+ -- For a nullary pattern synonym we add a single (# #) argument to the
-- matcher to preserve laziness in the case of unlifted types.
-- See #12746
compareArgTys :: [Type] -> [Type] -> Bool
- compareArgTys [] [x] = x `eqType` voidPrimTy
+ compareArgTys [] [x] = x `eqType` unboxedUnitTy
compareArgTys arg_tys matcher_arg_tys = arg_tys `eqTypes` matcher_arg_tys
diff --git a/compiler/GHC/Tc/TyCl/PatSyn.hs b/compiler/GHC/Tc/TyCl/PatSyn.hs
index 3f276f5945..0be256c93f 100644
--- a/compiler/GHC/Tc/TyCl/PatSyn.hs
+++ b/compiler/GHC/Tc/TyCl/PatSyn.hs
@@ -698,12 +698,12 @@ tcPatSynMatcher (L loc name) lpat
res_ty = mkTyVarTy res_tv
is_unlifted = null args && null prov_dicts
(cont_args, cont_arg_tys)
- | is_unlifted = ([nlHsVar voidPrimId], [voidPrimTy])
+ | is_unlifted = ([nlHsVar voidPrimId], [unboxedUnitTy])
| otherwise = (args, arg_tys)
cont_ty = mkInfSigmaTy ex_tvs prov_theta $
mkVisFunTysMany cont_arg_tys res_ty
- fail_ty = mkVisFunTyMany voidPrimTy res_ty
+ fail_ty = mkVisFunTyMany unboxedUnitTy res_ty
; matcher_name <- newImplicitBinder name mkMatcherOcc
; scrutinee <- newSysLocalId (fsLit "scrut") Many pat_ty
@@ -905,7 +905,7 @@ tcPatSynBuilderOcc ps
add_void :: Bool -> Type -> Type
add_void need_dummy_arg ty
- | need_dummy_arg = mkVisFunTyMany voidPrimTy ty
+ | need_dummy_arg = mkVisFunTyMany unboxedUnitTy ty
| otherwise = ty
tcPatToExpr :: Name -> [Located Name] -> LPat GhcRn
diff --git a/compiler/GHC/Types/Id/Make.hs b/compiler/GHC/Types/Id/Make.hs
index 3bd7fecd70..6d49479807 100644
--- a/compiler/GHC/Types/Id/Make.hs
+++ b/compiler/GHC/Types/Id/Make.hs
@@ -121,7 +121,7 @@ The ghcPrimIds
but have perfectly reasonable unfoldings in Core
* Either have a CompulsoryUnfolding (hence always inlined), or
- of an EvaldUnfolding and void representation (e.g. void#)
+ of an EvaldUnfolding and void representation (e.g. realWorldPrimId)
* Are (or should be) defined in primops.txt.pp as 'pseudoop'
Reason: that's how we generate documentation for them
@@ -1760,12 +1760,19 @@ realWorldPrimId = pcMiscPrelId realWorldName realWorldStatePrimTy
`setNeverLevPoly` realWorldStatePrimTy)
voidPrimId :: Id -- Global constant :: Void#
-voidPrimId = pcMiscPrelId voidPrimIdName voidPrimTy
- (noCafIdInfo `setUnfoldingInfo` evaldUnfolding -- Note [evaldUnfoldings]
- `setNeverLevPoly` voidPrimTy)
+ -- The type Void# is now the same as (# #) (ticket #18441),
+ -- this identifier just signifies the (# #) datacon
+ -- and is kept for backwards compatibility.
+ -- We cannot define it in normal Haskell, since it's
+ -- a top-level unlifted value.
+voidPrimId = pcMiscPrelId voidPrimIdName unboxedUnitTy
+ (noCafIdInfo `setUnfoldingInfo` mkCompulsoryUnfolding rhs
+ `setNeverLevPoly` unboxedUnitTy)
+ where rhs = Var (dataConWorkId unboxedUnitDataCon)
+
voidArgId :: Id -- Local lambda-bound :: Void#
-voidArgId = mkSysLocal (fsLit "void") voidArgIdKey Many voidPrimTy
+voidArgId = mkSysLocal (fsLit "void") voidArgIdKey Many unboxedUnitTy
coercionTokenId :: Id -- :: () ~ ()
coercionTokenId -- See Note [Coercion tokens] in "GHC.CoreToStg"
diff --git a/docs/users_guide/8.12.1-notes.rst b/docs/users_guide/8.12.1-notes.rst
index 1fe2e49894..dd429c22d4 100644
--- a/docs/users_guide/8.12.1-notes.rst
+++ b/docs/users_guide/8.12.1-notes.rst
@@ -336,6 +336,9 @@ Haddock
- Add a known-key ``cstringLength#`` to ``GHC.CString`` that is eligible
for constant folding by a built-in rule.
+- ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``.
+ Code using ``Void#`` now has to enable :extension:`UnboxedTuples`.
+
``ghc`` library
~~~~~~~~~~~~~~~
diff --git a/libraries/base/GHC/Exts.hs b/libraries/base/GHC/Exts.hs
index f6d7c43ca9..5a09d421d1 100755
--- a/libraries/base/GHC/Exts.hs
+++ b/libraries/base/GHC/Exts.hs
@@ -37,6 +37,7 @@ module GHC.Exts
uncheckedShiftL64#, uncheckedShiftRL64#,
uncheckedIShiftL64#, uncheckedIShiftRA64#,
isTrue#,
+ Void#, -- Previously exported by GHC.Prim
-- * Compat wrapper
atomicModifyMutVar#,
diff --git a/libraries/base/tests/isValidNatural.hs b/libraries/base/tests/isValidNatural.hs
index 4c9422f054..cd2ae4a9fc 100644
--- a/libraries/base/tests/isValidNatural.hs
+++ b/libraries/base/tests/isValidNatural.hs
@@ -1,4 +1,4 @@
-{-# language MagicHash #-}
+{-# language MagicHash, UnboxedTuples #-}
import GHC.Num.Natural
import GHC.Num.BigNat
@@ -7,4 +7,4 @@ import GHC.Exts
main = print $ map naturalCheck [0, 1, maxWord, maxWord + 1, invalid]
where
maxWord = fromIntegral (maxBound :: Word)
- invalid = NB (bigNatOne# void#) -- 1 would fit into the NS constructor.
+ invalid = NB (bigNatOne# (# #)) -- 1 would fit into the NS constructor.
diff --git a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
index 6b4523ad00..20a227f099 100644
--- a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
@@ -68,11 +68,11 @@ type BigNat# = WordArray#
-- As a consequence, zero is represented with a WordArray# whose size is 0.
data BigNat = BN# { unBigNat :: BigNat# }
--- Note [Why Void#?]
+-- Note [Why (# #)?]
-- ~~~~~~~~~~~~~~~~~
--
-- We can't have top-level BigNat# for now because they are unlifted ByteArray#
--- (see #17521). So we use functions that take an empty argument Void# that
+-- (see #17521). So we use functions that take an empty argument (# #) that
-- will be discarded at compile time.
@@ -104,18 +104,18 @@ bigNatOne :: BigNat
bigNatOne = BN# (bigNatFromWord# 1##)
-- | BigNat Zero
-bigNatZero# :: Void# -> BigNat# -- cf Note [Why Void#?]
+bigNatZero# :: (# #) -> BigNat# -- cf Note [Why (# #)?]
bigNatZero# _ = case bigNatZero of
BN# w -> w
-- | BigNat one
-bigNatOne# :: Void# -> BigNat# -- cf Note [Why Void#?]
+bigNatOne# :: (# #) -> BigNat# -- cf Note [Why (# #)?]
bigNatOne# _ = case bigNatOne of
BN# w -> w
-raiseDivZero_BigNat :: Void# -> BigNat#
+raiseDivZero_BigNat :: (# #) -> BigNat#
raiseDivZero_BigNat _ = case raiseDivZero of
- !_ -> bigNatZero# void#
+ !_ -> bigNatZero# (# #)
-- see Note [ghc-bignum exceptions] in GHC.Num.Primitives
-- | Indicate if a bigNat is zero
@@ -184,7 +184,7 @@ bigNatFromWord (W# w) = bigNatFromWord# w
-- | Create a BigNat from a Word
bigNatFromWord# :: Word# -> BigNat#
-bigNatFromWord# 0## = bigNatZero# void#
+bigNatFromWord# 0## = bigNatZero# (# #)
bigNatFromWord# w = wordArrayFromWord# w
-- | Convert a list of non-zero Words (most-significant first) into a BigNat
@@ -204,7 +204,7 @@ bigNatFromAbsInt# i = bigNatFromWord# (wordFromAbsInt# i)
-- | Convert a list of non-zero Words (most-significant first) into a BigNat.
-- Don't remove most-significant zero words
bigNatFromWordListUnsafe :: [Word] -> BigNat#
-bigNatFromWordListUnsafe [] = bigNatZero# void#
+bigNatFromWordListUnsafe [] = bigNatZero# (# #)
bigNatFromWordListUnsafe xs =
let
length i [] = i
@@ -227,7 +227,7 @@ bigNatToWordList bn = go (bigNatSize# bn)
-- | Convert two Word# (most-significant first) into a BigNat
bigNatFromWord2# :: Word# -> Word# -> BigNat#
-bigNatFromWord2# 0## 0## = bigNatZero# void#
+bigNatFromWord2# 0## 0## = bigNatZero# (# #)
bigNatFromWord2# 0## n = bigNatFromWord# n
bigNatFromWord2# w1 w2 = wordArrayFromWord2# w1 w2
@@ -415,9 +415,9 @@ bigNatAdd a b
-- | Multiply a BigNat by a Word#
bigNatMulWord# :: BigNat# -> Word# -> BigNat#
bigNatMulWord# a w
- | 0## <- w = bigNatZero# void#
+ | 0## <- w = bigNatZero# (# #)
| 1## <- w = a
- | bigNatIsZero a = bigNatZero# void#
+ | bigNatIsZero a = bigNatZero# (# #)
| bigNatIsOne a = bigNatFromWord# w
| isTrue# (bigNatSize# a ==# 1#)
= case timesWord2# (bigNatIndex# a 0#) w of
@@ -531,7 +531,7 @@ bigNatSub a b
bigNatQuotWord# :: BigNat# -> Word# -> BigNat#
bigNatQuotWord# a b
| 1## <- b = a
- | 0## <- b = raiseDivZero_BigNat void#
+ | 0## <- b = raiseDivZero_BigNat (# #)
| True =
let
sz = wordArraySize# a
@@ -551,7 +551,7 @@ bigNatQuotWord a (W# b) = bigNatQuotWord# a b
-- b /= 0
bigNatRemWord# :: BigNat# -> Word# -> Word#
bigNatRemWord# a b
- | 0## <- b = raiseDivZero_Word# void#
+ | 0## <- b = raiseDivZero_Word# (# #)
| 1## <- b = 0##
| bigNatIsZero a = 0##
| True = inline bignat_rem_word a b
@@ -570,14 +570,14 @@ bigNatRemWord a (W# b) = W# (bigNatRemWord# a b)
bigNatQuotRemWord# :: BigNat# -> Word# -> (# BigNat#, Word# #)
bigNatQuotRemWord# a b
| 0## <- b = case raiseDivZero of
- !_ -> (# bigNatZero# void#, 0## #)
+ !_ -> (# bigNatZero# (# #), 0## #)
-- see Note [ghc-bignum exceptions] in GHC.Num.Primitives
| 1## <- b = (# a, 0## #)
| isTrue# (bigNatSize# a ==# 1#)
, a0 <- indexWordArray# a 0#
= case compareWord# a0 b of
- LT -> (# bigNatZero# void#, a0 #)
- EQ -> (# bigNatOne# void#, 0## #)
+ LT -> (# bigNatZero# (# #), a0 #)
+ EQ -> (# bigNatOne# (# #), 0## #)
GT -> case quotRemWord# a0 b of
(# q, r #) -> (# bigNatFromWord# q, r #)
| True =
@@ -598,12 +598,12 @@ bigNatQuotRemWord# a b
bigNatQuotRem# :: BigNat# -> BigNat# -> (# BigNat#, BigNat# #)
bigNatQuotRem# a b
| bigNatIsZero b = case raiseDivZero of
- !_ -> (# bigNatZero# void#, bigNatZero# void# #)
+ !_ -> (# bigNatZero# (# #), bigNatZero# (# #) #)
-- see Note [ghc-bignum exceptions] in GHC.Num.Primitives
- | bigNatIsZero a = (# bigNatZero# void#, bigNatZero# void# #)
- | bigNatIsOne b = (# a , bigNatZero# void# #)
- | LT <- cmp = (# bigNatZero# void#, a #)
- | EQ <- cmp = (# bigNatOne# void#, bigNatZero# void# #)
+ | bigNatIsZero a = (# bigNatZero# (# #), bigNatZero# (# #) #)
+ | bigNatIsOne b = (# a , bigNatZero# (# #) #)
+ | LT <- cmp = (# bigNatZero# (# #), a #)
+ | EQ <- cmp = (# bigNatOne# (# #), bigNatZero# (# #) #)
| isTrue# (szB ==# 1#) = case bigNatQuotRemWord# a (bigNatIndex# b 0#) of
(# q, r #) -> (# q, bigNatFromWord# r #)
@@ -620,11 +620,11 @@ bigNatQuotRem# a b
-- | BigNat division returning quotient
bigNatQuot :: BigNat# -> BigNat# -> BigNat#
bigNatQuot a b
- | bigNatIsZero b = raiseDivZero_BigNat void#
- | bigNatIsZero a = bigNatZero# void#
+ | bigNatIsZero b = raiseDivZero_BigNat (# #)
+ | bigNatIsZero a = bigNatZero# (# #)
| bigNatIsOne b = a
- | LT <- cmp = bigNatZero# void#
- | EQ <- cmp = bigNatOne# void#
+ | LT <- cmp = bigNatZero# (# #)
+ | EQ <- cmp = bigNatOne# (# #)
| isTrue# (szB ==# 1#) = bigNatQuotWord# a (bigNatIndex# b 0#)
| True = withNewWordArrayTrimed# szQ \mwq s ->
inline bignat_quot mwq a b s
@@ -637,11 +637,11 @@ bigNatQuot a b
-- | BigNat division returning remainder
bigNatRem :: BigNat# -> BigNat# -> BigNat#
bigNatRem a b
- | bigNatIsZero b = raiseDivZero_BigNat void#
- | bigNatIsZero a = bigNatZero# void#
- | bigNatIsOne b = bigNatZero# void#
+ | bigNatIsZero b = raiseDivZero_BigNat (# #)
+ | bigNatIsZero a = bigNatZero# (# #)
+ | bigNatIsOne b = bigNatZero# (# #)
| LT <- cmp = a
- | EQ <- cmp = bigNatZero# void#
+ | EQ <- cmp = bigNatZero# (# #)
| isTrue# (szB ==# 1#) = case bigNatRemWord# a (bigNatIndex# b 0#) of
r -> bigNatFromWord# r
| True = withNewWordArrayTrimed# szR \mwr s ->
@@ -719,8 +719,8 @@ bigNatGcdWord# a b
-- | Least common multiple
bigNatLcm :: BigNat# -> BigNat# -> BigNat#
bigNatLcm a b
- | bigNatIsZero a = bigNatZero# void#
- | bigNatIsZero b = bigNatZero# void#
+ | bigNatIsZero a = bigNatZero# (# #)
+ | bigNatIsZero b = bigNatZero# (# #)
| bigNatIsOne a = b
| bigNatIsOne b = a
| True
@@ -734,8 +734,8 @@ bigNatLcm a b
-- | Least common multiple with a Word#
bigNatLcmWord# :: BigNat# -> Word# -> BigNat#
bigNatLcmWord# a b
- | bigNatIsZero a = bigNatZero# void#
- | 0## <- b = bigNatZero# void#
+ | bigNatIsZero a = bigNatZero# (# #)
+ | 0## <- b = bigNatZero# (# #)
| bigNatIsOne a = bigNatFromWord# b
| 1## <- b = a
| 1# <- bigNatSize# a = bigNatLcmWordWord# (bigNatIndex# a 0#) b
@@ -746,8 +746,8 @@ bigNatLcmWord# a b
-- | Least common multiple between two Word#
bigNatLcmWordWord# :: Word# -> Word# -> BigNat#
bigNatLcmWordWord# a b
- | 0## <- a = bigNatZero# void#
- | 0## <- b = bigNatZero# void#
+ | 0## <- a = bigNatZero# (# #)
+ | 0## <- b = bigNatZero# (# #)
| 1## <- a = bigNatFromWord# b
| 1## <- b = bigNatFromWord# a
| True = case (a `quotWord#` (a `gcdWord#` b)) `timesWord2#` b of
@@ -879,7 +879,7 @@ bigNatShiftR# a n
| nw <- word2Int# (n `uncheckedShiftRL#` WORD_SIZE_BITS_SHIFT#)
, isTrue# (nw >=# wordArraySize# a)
- = bigNatZero# void#
+ = bigNatZero# (# #)
| True
= let
@@ -900,7 +900,7 @@ bigNatShiftRNeg# a n
| nw <- word2Int# (n `uncheckedShiftRL#` WORD_SIZE_BITS_SHIFT#)
, isTrue# (nw >=# wordArraySize# a)
- = bigNatZero# void#
+ = bigNatZero# (# #)
| True
= let
@@ -961,7 +961,7 @@ bigNatTestBit a (W# n) = isTrue# (bigNatTestBit# a n)
--
bigNatBit# :: Word# -> BigNat#
bigNatBit# i
- | 0## <- i = bigNatOne# void#
+ | 0## <- i = bigNatOne# (# #)
| True =
let
!nw = word2Int# (i `uncheckedShiftRL#` WORD_SIZE_BITS_SHIFT#)
@@ -1000,7 +1000,7 @@ bigNatClearBit# a n
| 0## <- nv
, isTrue# (nw +# 1# ==# sz)
-> case sz -# (waClzAt a (sz -# 2#) +# 1#) of
- 0# -> bigNatZero# void#
+ 0# -> bigNatZero# (# #)
nsz -> withNewWordArray# nsz \mwa s ->
mwaArrayCopy# mwa 0# a 0# nsz s
@@ -1060,7 +1060,7 @@ bigNatLog2 a = W# (bigNatLog2# a)
bigNatLogBase# :: BigNat# -> BigNat# -> Word#
bigNatLogBase# base a
| bigNatIsZero base || bigNatIsOne base
- = unexpectedValue_Word# void#
+ = unexpectedValue_Word# (# #)
| 1# <- bigNatSize# base
, 2## <- bigNatIndex# base 0#
@@ -1086,8 +1086,8 @@ bigNatLogBase base a = W# (bigNatLogBase# base a)
-- | Logarithm for an arbitrary base
bigNatLogBaseWord# :: Word# -> BigNat# -> Word#
bigNatLogBaseWord# base a
- | 0## <- base = unexpectedValue_Word# void#
- | 1## <- base = unexpectedValue_Word# void#
+ | 0## <- base = unexpectedValue_Word# (# #)
+ | 1## <- base = unexpectedValue_Word# (# #)
| 2## <- base = bigNatLog2# a
-- TODO: optimize log base power of 2 (256, etc.)
| True = bigNatLogBase# (bigNatFromWord# base) a
@@ -1106,7 +1106,7 @@ bigNatLogBaseWord (W# base) a = W# (bigNatLogBaseWord# base a)
bigNatSizeInBase# :: Word# -> BigNat# -> Word#
bigNatSizeInBase# base a
| isTrue# (base `leWord#` 1##)
- = unexpectedValue_Word# void#
+ = unexpectedValue_Word# (# #)
| bigNatIsZero a
= 0##
@@ -1135,7 +1135,7 @@ powModWord# = bignat_powmod_words
-- | \"@'bigNatPowModWord#' /b/ /e/ /m/@\" computes base @/b/@ raised to
-- exponent @/e/@ modulo @/m/@.
bigNatPowModWord# :: BigNat# -> BigNat# -> Word# -> Word#
-bigNatPowModWord# !_ !_ 0## = raiseDivZero_Word# void#
+bigNatPowModWord# !_ !_ 0## = raiseDivZero_Word# (# #)
bigNatPowModWord# _ _ 1## = 0##
bigNatPowModWord# b e m
| bigNatIsZero e = 1##
@@ -1149,7 +1149,7 @@ bigNatPowMod :: BigNat# -> BigNat# -> BigNat# -> BigNat#
bigNatPowMod !b !e !m
| (# m' | #) <- bigNatToWordMaybe# m
= bigNatFromWord# (bigNatPowModWord# b e m')
- | bigNatIsZero m = raiseDivZero_BigNat void#
+ | bigNatIsZero m = raiseDivZero_BigNat (# #)
| bigNatIsOne m = bigNatFromWord# 0##
| bigNatIsZero e = bigNatFromWord# 1##
| bigNatIsZero b = bigNatFromWord# 0##
@@ -1293,7 +1293,7 @@ bigNatToAddr a addr e = IO \s -> case bigNatToAddr# a addr e s of
--
-- Higher limbs equal to 0 are automatically trimed.
bigNatFromAddrLE# :: Word# -> Addr# -> State# s -> (# State# s, BigNat# #)
-bigNatFromAddrLE# 0## _ s = (# s, bigNatZero# void# #)
+bigNatFromAddrLE# 0## _ s = (# s, bigNatZero# (# #) #)
bigNatFromAddrLE# sz addr s =
let
!nw = sz `uncheckedShiftRL#` WORD_SIZE_BYTES_SHIFT#
@@ -1328,7 +1328,7 @@ bigNatFromAddrLE# sz addr s =
--
-- Null higher limbs are automatically trimed.
bigNatFromAddrBE# :: Word# -> Addr# -> State# s -> (# State# s, BigNat# #)
-bigNatFromAddrBE# 0## _ s = (# s, bigNatZero# void# #)
+bigNatFromAddrBE# 0## _ s = (# s, bigNatZero# (# #) #)
bigNatFromAddrBE# sz addr s =
let
!nw = word2Int# (sz `uncheckedShiftRL#` WORD_SIZE_BYTES_SHIFT#)
@@ -1454,7 +1454,7 @@ bigNatToMutableByteArray# a mba off _ s = bigNatToMutableByteArrayBE# a mba off
--
-- Null higher limbs are automatically trimed.
bigNatFromByteArrayLE# :: Word# -> ByteArray# -> Word# -> State# s -> (# State# s, BigNat# #)
-bigNatFromByteArrayLE# 0## _ _ s = (# s, bigNatZero# void# #)
+bigNatFromByteArrayLE# 0## _ _ s = (# s, bigNatZero# (# #) #)
bigNatFromByteArrayLE# sz ba moff s =
let
!nw = sz `uncheckedShiftRL#` WORD_SIZE_BYTES_SHIFT#
@@ -1489,7 +1489,7 @@ bigNatFromByteArrayLE# sz ba moff s =
--
-- Null higher limbs are automatically trimed.
bigNatFromByteArrayBE# :: Word# -> ByteArray# -> Word# -> State# s -> (# State# s, BigNat# #)
-bigNatFromByteArrayBE# 0## _ _ s = (# s, bigNatZero# void# #)
+bigNatFromByteArrayBE# 0## _ _ s = (# s, bigNatZero# (# #) #)
bigNatFromByteArrayBE# sz ba moff s =
let
!nw = sz `uncheckedShiftRL#` WORD_SIZE_BYTES_SHIFT#
diff --git a/libraries/ghc-bignum/src/GHC/Num/BigNat/Check.hs b/libraries/ghc-bignum/src/GHC/Num/BigNat/Check.hs
index 011330cf5e..f19eceb3e7 100644
--- a/libraries/ghc-bignum/src/GHC/Num/BigNat/Check.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/BigNat/Check.hs
@@ -42,7 +42,7 @@ bignat_compare a b =
gr = Other.bignat_compare a b
nr = Native.bignat_compare a b
in case gr ==# nr of
- 0# -> unexpectedValue_Int# void#
+ 0# -> unexpectedValue_Int# (# #)
_ -> gr
mwaCompare
@@ -380,7 +380,7 @@ bignat_rem_word wa b =
nr = Native.bignat_rem_word wa b
in case gr `eqWord#` nr of
1# -> gr
- _ -> unexpectedValue_Word# void#
+ _ -> unexpectedValue_Word# (# #)
bignat_gcd
:: MutableWordArray# RealWorld
@@ -403,7 +403,7 @@ bignat_gcd_word wa b =
nr = Native.bignat_gcd_word wa b
in case gr `eqWord#` nr of
1# -> gr
- _ -> unexpectedValue_Word# void#
+ _ -> unexpectedValue_Word# (# #)
bignat_gcd_word_word
:: Word#
@@ -415,7 +415,7 @@ bignat_gcd_word_word a b =
nr = Native.bignat_gcd_word_word a b
in case gr `eqWord#` nr of
1# -> gr
- _ -> unexpectedValue_Word# void#
+ _ -> unexpectedValue_Word# (# #)
bignat_encode_double :: WordArray# -> Int# -> Double#
bignat_encode_double a e =
@@ -435,7 +435,7 @@ bignat_powmod_word b e m =
nr = Native.bignat_powmod_word b e m
in case gr `eqWord#` nr of
1# -> gr
- _ -> unexpectedValue_Word# void#
+ _ -> unexpectedValue_Word# (# #)
bignat_powmod
:: MutableWordArray# RealWorld
@@ -460,4 +460,4 @@ bignat_powmod_words b e m =
nr = Native.bignat_powmod_words b e m
in case gr `eqWord#` nr of
1# -> gr
- _ -> unexpectedValue_Word# void#
+ _ -> unexpectedValue_Word# (# #)
diff --git a/libraries/ghc-bignum/src/GHC/Num/Integer.hs b/libraries/ghc-bignum/src/GHC/Num/Integer.hs
index 57bb8dbadf..04dd57b291 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Integer.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Integer.hs
@@ -120,7 +120,7 @@ integerToBigNatClamp# :: Integer -> BigNat#
integerToBigNatClamp# (IP x) = x
integerToBigNatClamp# (IS x)
| isTrue# (x >=# 0#) = bigNatFromWord# (int2Word# x)
-integerToBigNatClamp# _ = bigNatZero# void#
+integerToBigNatClamp# _ = bigNatZero# (# #)
-- | Create an Integer from an Int#
integerFromInt# :: Int# -> Integer
diff --git a/libraries/ghc-bignum/src/GHC/Num/Primitives.hs b/libraries/ghc-bignum/src/GHC/Num/Primitives.hs
index 358c83b3be..033262b229 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Primitives.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Primitives.hs
@@ -247,7 +247,7 @@ wordLog2# w = (WORD_SIZE_IN_BITS## `minusWord#` 1##) `minusWord#` (clz# w)
wordLogBase# :: Word# -> Word# -> Word#
wordLogBase# base a
| isTrue# (base `leWord#` 1##)
- = unexpectedValue_Word# void#
+ = unexpectedValue_Word# (# #)
| 2## <- base
= wordLog2# a
@@ -616,19 +616,19 @@ ioBool (IO io) s = case io s of
-- -- 0## is a dummy value (unreachable code)
--
-unexpectedValue_Int# :: Void# -> Int#
+unexpectedValue_Int# :: (# #) -> Int#
unexpectedValue_Int# _ = case unexpectedValue of
!_ -> 0# -- see Note [ghc-bignum exceptions]
-unexpectedValue_Word# :: Void# -> Word#
+unexpectedValue_Word# :: (# #) -> Word#
unexpectedValue_Word# _ = case unexpectedValue of
!_ -> 0## -- see Note [ghc-bignum exceptions]
-raiseDivZero_Word# :: Void# -> Word#
+raiseDivZero_Word# :: (# #) -> Word#
raiseDivZero_Word# _ = case raiseDivZero of
!_ -> 0## -- see Note [ghc-bignum exceptions]
-raiseUnderflow_Word# :: Void# -> Word#
+raiseUnderflow_Word# :: (# #) -> Word#
raiseUnderflow_Word# _ = case raiseUnderflow of
!_ -> 0## -- see Note [ghc-bignum exceptions]
diff --git a/libraries/ghc-prim/GHC/Prim/Exception.hs b/libraries/ghc-prim/GHC/Prim/Exception.hs
index 36889dc1e3..592d597f44 100644
--- a/libraries/ghc-prim/GHC/Prim/Exception.hs
+++ b/libraries/ghc-prim/GHC/Prim/Exception.hs
@@ -28,9 +28,9 @@ default () -- Double and Integer aren't available yet
-- raise exceptions in a normal way because it would create a dependency
-- cycle (base <-> bignum package). See #14664
-foreign import prim "stg_raiseOverflowzh" raiseOverflow# :: State# RealWorld -> (# State# RealWorld, Void# #)
-foreign import prim "stg_raiseUnderflowzh" raiseUnderflow# :: State# RealWorld -> (# State# RealWorld, Void# #)
-foreign import prim "stg_raiseDivZZerozh" raiseDivZero# :: State# RealWorld -> (# State# RealWorld, Void# #)
+foreign import prim "stg_raiseOverflowzh" raiseOverflow# :: State# RealWorld -> (# State# RealWorld, (# #) #)
+foreign import prim "stg_raiseUnderflowzh" raiseUnderflow# :: State# RealWorld -> (# State# RealWorld, (# #) #)
+foreign import prim "stg_raiseDivZZerozh" raiseDivZero# :: State# RealWorld -> (# State# RealWorld, (# #) #)
-- We give a bottoming demand signature to 'raiseOverflow', 'raiseUnderflow' and
-- 'raiseDivZero' in "GHC.Core.Make". NOINLINE pragmas are necessary because if
diff --git a/libraries/ghc-prim/GHC/Prim/Panic.hs b/libraries/ghc-prim/GHC/Prim/Panic.hs
index 8dd8f03530..21ebc56a88 100644
--- a/libraries/ghc-prim/GHC/Prim/Panic.hs
+++ b/libraries/ghc-prim/GHC/Prim/Panic.hs
@@ -18,8 +18,8 @@ import GHC.Magic
default () -- Double and Integer aren't available yet
-- `stg_panic#` never returns but it can't just return `State# RealWorld` so we
--- indicate that it returns `Void#` too to make the compiler happy.
-foreign import prim "stg_paniczh" panic# :: Addr# -> State# RealWorld -> (# State# RealWorld, Void# #)
+-- indicate that it returns `(# #)` too to make the compiler happy.
+foreign import prim "stg_paniczh" panic# :: Addr# -> State# RealWorld -> (# State# RealWorld, (# #) #)
-- | Display the CString whose address is given as an argument and exit.
panicError :: Addr# -> a
diff --git a/libraries/ghc-prim/GHC/Types.hs b/libraries/ghc-prim/GHC/Types.hs
index 2607f177ae..5198a486e4 100644
--- a/libraries/ghc-prim/GHC/Types.hs
+++ b/libraries/ghc-prim/GHC/Types.hs
@@ -38,6 +38,7 @@ module GHC.Types (
-- `type *`, without the parentheses. But that's a true
-- pain to parse, and for little gain.
VecCount(..), VecElem(..),
+ Void#,
-- * Runtime type representation
Module(..), TrName(..), TyCon(..), TypeLitSort(..),
@@ -462,6 +463,9 @@ data VecElem = Int8ElemRep
| DoubleElemRep
-- Enum, Bounded instances in GHC.Enum
+{-# DEPRECATED Void# "Void# is now an alias for the unboxed tuple (# #)." #-}
+type Void# = (# #)
+
{- *********************************************************************
* *
Runtime representation of TyCon
diff --git a/testsuite/tests/codeGen/should_compile/T12115.hs b/testsuite/tests/codeGen/should_compile/T12115.hs
index 9cbb1b6bbd..bc119e58b4 100644
--- a/testsuite/tests/codeGen/should_compile/T12115.hs
+++ b/testsuite/tests/codeGen/should_compile/T12115.hs
@@ -5,5 +5,5 @@ module T12115 where
import GHC.Prim
import GHC.Types
-f :: (# Void#, (# #) #) -> String
+f :: (# (# #), (# #) #) -> String
f = f
diff --git a/testsuite/tests/printer/T18052a.stderr b/testsuite/tests/printer/T18052a.stderr
index 428855692b..a45c9c958c 100644
--- a/testsuite/tests/printer/T18052a.stderr
+++ b/testsuite/tests/printer/T18052a.stderr
@@ -25,7 +25,7 @@ T18052a.$b:||: = \ (@a) (@b) (x :: a) (y :: b) -> (x, y)
-- RHS size: {terms: 13, types: 20, coercions: 0, joins: 0/0}
T18052a.$m:||:
:: forall {rep :: GHC.Types.RuntimeRep} {r :: TYPE rep} {a} {b}.
- (a, b) -> (a -> b -> r) -> (GHC.Prim.Void# -> r) -> r
+ (a, b) -> (a -> b -> r) -> ((# #) -> r) -> r
[GblId, Arity=3, Unf=OtherCon []]
T18052a.$m:||:
= \ (@(rep :: GHC.Types.RuntimeRep))
diff --git a/testsuite/tests/simplCore/should_compile/T13143.stderr b/testsuite/tests/simplCore/should_compile/T13143.stderr
index 13f6d769ec..6d069f6cbd 100644
--- a/testsuite/tests/simplCore/should_compile/T13143.stderr
+++ b/testsuite/tests/simplCore/should_compile/T13143.stderr
@@ -6,9 +6,9 @@ Result size of Tidy Core
Rec {
-- RHS size: {terms: 4, types: 4, coercions: 0, joins: 0/0}
T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker]
- :: forall {a}. GHC.Prim.Void# -> a
+ :: forall {a}. (# #) -> a
[GblId, Arity=1, Str=<B,A>b, Cpr=b, Unf=OtherCon []]
-T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.void#
+T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)
end Rec }
-- RHS size: {terms: 4, types: 4, coercions: 0, joins: 0/0}
@@ -20,8 +20,8 @@ f [InlPrag=NOUSERINLINE[final]] :: forall a. Int -> a
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)
- Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.void#}]
-f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.void#
+ Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)}]
+f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
T13143.$trModule4 :: GHC.Prim.Addr#
@@ -62,7 +62,7 @@ T13143.$trModule
-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0}
lvl :: Int
[GblId, Str=b, Cpr=b]
-lvl = T13143.$wf @Int GHC.Prim.void#
+lvl = T13143.$wf @Int GHC.Prim.(##)
Rec {
-- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0}
diff --git a/testsuite/tests/unboxedsums/ffi1.hs b/testsuite/tests/unboxedsums/ffi1.hs
index e6128e4ff1..aff0e73799 100644
--- a/testsuite/tests/unboxedsums/ffi1.hs
+++ b/testsuite/tests/unboxedsums/ffi1.hs
@@ -2,7 +2,7 @@
module Lib where
-import GHC.Prim
+import GHC.Exts
-- Can't unboxed tuples and sums to FFI, we should fail appropriately.
diff --git a/utils/genprimopcode/Main.hs b/utils/genprimopcode/Main.hs
index 3fe744fec3..004199a9a4 100644
--- a/utils/genprimopcode/Main.hs
+++ b/utils/genprimopcode/Main.hs
@@ -923,8 +923,6 @@ ppType (TyApp (TyCon "IOPort#") [x,y]) = "mkIOPortPrimTy " ++ ppType x
++ " " ++ ppType y
ppType (TyApp (TyCon "TVar#") [x,y]) = "mkTVarPrimTy " ++ ppType x
++ " " ++ ppType y
-ppType (TyApp (TyCon "Void#") []) = "voidPrimTy"
-
ppType (TyApp (VecTyCon _ pptc) []) = pptc
ppType (TyUTup ts) = "(mkTupleTy Unboxed "