summaryrefslogtreecommitdiff
path: root/libraries/ghc-prim/GHC/Prim/Panic.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ghc-prim/GHC/Prim/Panic.hs')
-rw-r--r--libraries/ghc-prim/GHC/Prim/Panic.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/libraries/ghc-prim/GHC/Prim/Panic.hs b/libraries/ghc-prim/GHC/Prim/Panic.hs
index a6f1eb588b..a24f82ee07 100644
--- a/libraries/ghc-prim/GHC/Prim/Panic.hs
+++ b/libraries/ghc-prim/GHC/Prim/Panic.hs
@@ -4,6 +4,7 @@
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE EmptyCase #-}
+{-# LANGUAGE RankNTypes, KindSignatures #-}
-- | Primitive panics.
--
@@ -11,12 +12,13 @@
module GHC.Prim.Panic
( absentSumFieldError
, panicError
- , absentError
+ , absentError, absentConstraintError
)
where
import GHC.Prim
import GHC.Magic
+import GHC.Types( Type )
default () -- Double and Integer aren't available yet
@@ -95,7 +97,7 @@ absentSumFieldError = panicError "entered absent sum field!"#
-- | Displays "Oops! Entered absent arg" ++ errormsg and exits the program.
{-# NOINLINE absentError #-}
-absentError :: Addr# -> a
+absentError :: forall (a :: Type). Addr# -> a
absentError errmsg =
runRW# (\s ->
case stg_absentError# errmsg s of
@@ -103,3 +105,15 @@ absentError errmsg =
-- use an empty case lest the pattern match
-- checker squawks.
let x = x in x)
+
+{-# NOINLINE absentConstraintError #-}
+absentConstraintError :: forall (a :: Type). Addr# -> a
+-- We want to give this the type
+-- forall (a :: Constraint). Addr# -> a
+-- but Haskell source code doesn't allow functions that return Constraint
+-- Fortunately, absentConstraintError is a wired-in Id with the above
+-- desired type. So the only purpose of this definition is to give a
+-- function to call. And for that purpose, absentError will do fine.
+-- It's fine to lie about about the type; it is not looked at
+-- because absentConstraintError is wired-in.
+absentConstraintError errmsg = absentError errmsg