Commit 6740d70d authored by Eric Seidel's avatar Eric Seidel Committed by Ben Gamari
Browse files

Use IP based CallStack in error and undefined

This patch modifies `error`, `undefined`, and `assertError` to use
implicit call-stacks to provide better error messages to users.

There are a few knock-on effects:

- `GHC.Classes.IP` is now wired-in so it can be used in the wired-in
  types for `error` and `undefined`.

- `TysPrim.tyVarList` has been replaced with a new function
  `TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce
  subtle bugs when you need tyvars of different kinds. The naive

  ```
  tv1 = head $ tyVarList kind1
  tv2 = head $ tyVarList kind2
  ```

  would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions
  would be applied incorrectly, treating `tv1` and `tv2` as the same
  tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds
  and producing a single tyvar of each kind.

- The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in
  ghc-prim.

- The type `GHC.Exception.ErrorCall` has a new constructor
  `ErrorCallWithLocation` that takes two `String`s instead of one, the
  2nd one being arbitrary metadata about the error (but usually the
  call-stack). A bi-directional pattern synonym `ErrorCall` continues to
  provide the old API.

Updates Cabal, array, and haddock submodules.

Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter,
liyang, bgamari, thomie

Differential Revision: https://phabricator.haskell.org/D861

GHC Trac Issues: #5273
parent ad26c54b
......@@ -1088,7 +1088,7 @@ proxyHashId
ty = mkForAllTys [kv, tv] (mkProxyPrimTy k t)
kv = kKiVar
k = mkTyVarTy kv
tv:_ = tyVarList k
[tv] = mkTemplateTyVars [k]
t = mkTyVarTy tv
------------------------------------------------
......
......@@ -717,19 +717,30 @@ errorName :: Name
errorName = mkWiredInIdName gHC_ERR (fsLit "error") errorIdKey eRROR_ID
eRROR_ID :: Id
eRROR_ID = pc_bottoming_Id1 errorName errorTy
eRROR_ID = pc_bottoming_Id2 errorName errorTy
errorTy :: Type -- See Note [Error and friends have an "open-tyvar" forall]
errorTy = mkSigmaTy [openAlphaTyVar] [] (mkFunTys [mkListTy charTy] openAlphaTy)
errorTy = mkSigmaTy [openAlphaTyVar] []
(mkFunTys [ mkClassPred
ipClass
[ mkStrLitTy (fsLit "callStack")
, mkTyConTy callStackTyCon ]
, mkListTy charTy]
openAlphaTy)
undefinedName :: Name
undefinedName = mkWiredInIdName gHC_ERR (fsLit "undefined") undefinedKey uNDEFINED_ID
uNDEFINED_ID :: Id
uNDEFINED_ID = pc_bottoming_Id0 undefinedName undefinedTy
uNDEFINED_ID = pc_bottoming_Id1 undefinedName undefinedTy
undefinedTy :: Type -- See Note [Error and friends have an "open-tyvar" forall]
undefinedTy = mkSigmaTy [openAlphaTyVar] [] openAlphaTy
undefinedTy = mkSigmaTy [openAlphaTyVar] []
(mkFunTy (mkClassPred
ipClass
[ mkStrLitTy (fsLit "callStack")
, mkTyConTy callStackTyCon ])
openAlphaTy)
{-
Note [Error and friends have an "open-tyvar" forall]
......@@ -773,10 +784,11 @@ pc_bottoming_Id1 name ty
strict_sig = mkClosedStrictSig [evalDmd] botRes
-- These "bottom" out, no matter what their arguments
pc_bottoming_Id0 :: Name -> Type -> Id
-- Same but arity zero
pc_bottoming_Id0 name ty
pc_bottoming_Id2 :: Name -> Type -> Id
-- Same but arity two
pc_bottoming_Id2 name ty
= mkVanillaGlobalWithInfo name ty bottoming_info
where
bottoming_info = vanillaIdInfo `setStrictnessInfo` strict_sig
strict_sig = mkClosedStrictSig [] botRes
`setArityInfo` 2
strict_sig = mkClosedStrictSig [evalDmd, evalDmd] botRes
......@@ -61,7 +61,7 @@ import Var
-- import RnEnv( FastStringEnv, mkFsEnv, lookupFsEnv )
import TysWiredIn
import TysPrim
import PrelNames( funTyConKey, ipClassName )
import PrelNames( funTyConKey )
import Name
import BasicTypes
import Binary
......@@ -636,7 +636,7 @@ pprIfaceTypeApp tc args = sdocWithDynFlags (pprTyTcApp TopPrec tc args)
pprTyTcApp :: TyPrec -> IfaceTyCon -> IfaceTcArgs -> DynFlags -> SDoc
pprTyTcApp ctxt_prec tc tys dflags
| ifaceTyConName tc == ipClassName
| ifaceTyConName tc == getName ipTyCon
, ITC_Type (IfaceLitTy (IfaceStrTyLit n)) (ITC_Type ty ITC_Nil) <- tys
= char '?' <> ftext n <> ptext (sLit "::") <> ppr_ty TopPrec ty
......
......@@ -320,9 +320,6 @@ basicKnownKeyNames
-- Type-level naturals
knownNatClassName, knownSymbolClassName,
-- Implicit parameters
ipClassName,
-- Source locations
callStackDataConName, callStackTyConName,
srcLocDataConName,
......@@ -1172,18 +1169,14 @@ knownNatClassName = clsQual gHC_TYPELITS (fsLit "KnownNat") knownNatClassNam
knownSymbolClassName :: Name
knownSymbolClassName = clsQual gHC_TYPELITS (fsLit "KnownSymbol") knownSymbolClassNameKey
-- Implicit parameters
ipClassName :: Name
ipClassName = clsQual gHC_CLASSES (fsLit "IP") ipClassNameKey
-- Source Locations
callStackDataConName, callStackTyConName, srcLocDataConName :: Name
callStackDataConName
= dcQual gHC_STACK (fsLit "CallStack") callStackDataConKey
= dcQual gHC_TYPES (fsLit "CallStack") callStackDataConKey
callStackTyConName
= tcQual gHC_STACK (fsLit "CallStack") callStackTyConKey
= tcQual gHC_TYPES (fsLit "CallStack") callStackTyConKey
srcLocDataConName
= dcQual gHC_SRCLOC (fsLit "SrcLoc") srcLocDataConKey
= dcQual gHC_TYPES (fsLit "SrcLoc") srcLocDataConKey
-- plugins
pLUGINS :: Module
......@@ -1312,9 +1305,6 @@ knownSymbolClassNameKey = mkPreludeClassUnique 43
ghciIoClassKey :: Unique
ghciIoClassKey = mkPreludeClassUnique 44
ipClassNameKey :: Unique
ipClassNameKey = mkPreludeClassUnique 45
{-
************************************************************************
* *
......@@ -1540,6 +1530,14 @@ callStackTyConKey = mkPreludeTyConUnique 182
typeRepTyConKey :: Unique
typeRepTyConKey = mkPreludeTyConUnique 183
-- Implicit Parameters
ipTyConKey :: Unique
ipTyConKey = mkPreludeTyConUnique 184
ipCoNameKey :: Unique
ipCoNameKey = mkPreludeTyConUnique 185
---------------- Template Haskell -------------------
-- USES TyConUniques 200-299
-----------------------------------------------------
......@@ -1615,6 +1613,9 @@ callStackDataConKey, srcLocDataConKey :: Unique
callStackDataConKey = mkPreludeDataConUnique 36
srcLocDataConKey = mkPreludeDataConUnique 37
ipDataConKey :: Unique
ipDataConKey = mkPreludeDataConUnique 38
{-
************************************************************************
* *
......
......@@ -10,7 +10,8 @@
-- | This module defines TyCons that can't be expressed in Haskell.
-- They are all, therefore, wired-in TyCons. C.f module TysWiredIn
module TysPrim(
tyVarList, alphaTyVars, betaTyVars, alphaTyVar, betaTyVar, gammaTyVar, deltaTyVar,
mkTemplateTyVars,
alphaTyVars, betaTyVars, alphaTyVar, betaTyVar, gammaTyVar, deltaTyVar,
alphaTy, betaTy, gammaTy, deltaTy,
openAlphaTy, openBetaTy, openAlphaTyVar, openBetaTyVar, openAlphaTyVars,
kKiVar,
......@@ -205,18 +206,19 @@ alphaTyVars is a list of type variables for use in templates:
["a", "b", ..., "z", "t1", "t2", ... ]
-}
tyVarList :: Kind -> [TyVar]
tyVarList kind = [ mkTyVar (mkInternalName (mkAlphaTyVarUnique u)
(mkTyVarOccFS (mkFastString name))
noSrcSpan) kind
| u <- [2..],
let name | c <= 'z' = [c]
| otherwise = 't':show u
where c = chr (u-2 + ord 'a')
]
mkTemplateTyVars :: [Kind] -> [TyVar]
mkTemplateTyVars kinds =
[ mkTyVar (mkInternalName (mkAlphaTyVarUnique u)
(mkTyVarOccFS (mkFastString name))
noSrcSpan) k
| (k,u) <- zip kinds [2..],
let name | c <= 'z' = [c]
| otherwise = 't':show u
where c = chr (u-2 + ord 'a')
]
alphaTyVars :: [TyVar]
alphaTyVars = tyVarList liftedTypeKind
alphaTyVars = mkTemplateTyVars $ repeat liftedTypeKind
betaTyVars :: [TyVar]
betaTyVars = tail alphaTyVars
......@@ -234,14 +236,15 @@ alphaTy, betaTy, gammaTy, deltaTy :: Type
-- result type for "error", so that we can have (error Int# "Help")
openAlphaTyVars :: [TyVar]
openAlphaTyVar, openBetaTyVar :: TyVar
openAlphaTyVars@(openAlphaTyVar:openBetaTyVar:_) = tyVarList openTypeKind
openAlphaTyVars@(openAlphaTyVar:openBetaTyVar:_)
= mkTemplateTyVars $ repeat openTypeKind
openAlphaTy, openBetaTy :: Type
openAlphaTy = mkTyVarTy openAlphaTyVar
openBetaTy = mkTyVarTy openBetaTyVar
kKiVar :: KindVar
kKiVar = (tyVarList superKind) !! 10
kKiVar = (mkTemplateTyVars $ repeat superKind) !! 10
{-
************************************************************************
......
......@@ -75,6 +75,11 @@ module TysWiredIn (
eqTyCon_RDR, eqTyCon, eqTyConName, eqBoxDataCon,
coercibleTyCon, coercibleDataCon, coercibleClass,
-- * Implicit Parameters
ipTyCon, ipDataCon, ipClass,
callStackTyCon,
mkWiredInTyConName -- This is used in TcTypeNats to define the
-- built-in functions for evaluation.
) where
......@@ -88,6 +93,8 @@ import PrelNames
import TysPrim
-- others:
import CoAxiom
import Coercion
import Constants ( mAX_TUPLE_SIZE, mAX_CTUPLE_SIZE )
import Module ( Module )
import Type ( mkTyConApp )
......@@ -160,6 +167,7 @@ wiredInTyCons = [ unitTyCon -- Not treated like other tuples, because
, coercibleTyCon
, typeNatKindCon
, typeSymbolKindCon
, ipTyCon
]
mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
......@@ -174,6 +182,13 @@ mkWiredInDataConName built_in modu fs unique datacon
(AConLike (RealDataCon datacon)) -- Relevant DataCon
built_in
mkWiredInCoAxiomName :: BuiltInSyntax -> Module -> FastString -> Unique
-> CoAxiom Branched -> Name
mkWiredInCoAxiomName built_in modu fs unique ax
= mkWiredInName modu (mkTcOccFS fs) unique
(ACoAxiom ax) -- Relevant CoAxiom
built_in
-- See Note [Kind-changing of (~) and Coercible]
eqTyConName, eqBoxDataConName :: Name
eqTyConName = mkWiredInTyConName BuiltInSyntax gHC_TYPES (fsLit "~") eqTyConKey eqTyCon
......@@ -896,14 +911,14 @@ eqTyCon = mkAlgTyCon eqTyConName
where
kv = kKiVar
k = mkTyVarTy kv
a:b:_ = tyVarList k
[a,b] = mkTemplateTyVars [k,k]
eqBoxDataCon :: DataCon
eqBoxDataCon = pcDataCon eqBoxDataConName args [TyConApp eqPrimTyCon (map mkTyVarTy args)] eqTyCon
where
kv = kKiVar
k = mkTyVarTy kv
a:b:_ = tyVarList k
[a,b] = mkTemplateTyVars [k,k]
args = [kv, a, b]
......@@ -914,7 +929,7 @@ coercibleTyCon = mkClassTyCon
where kind = (ForAllTy kv $ mkArrowKinds [k, k] constraintKind)
kv = kKiVar
k = mkTyVarTy kv
a:b:_ = tyVarList k
[a,b] = mkTemplateTyVars [k,k]
tvs = [kv, a, b]
rhs = DataTyCon [coercibleDataCon] False
......@@ -923,8 +938,59 @@ coercibleDataCon = pcDataCon coercibleDataConName args [TyConApp eqReprPrimTyCon
where
kv = kKiVar
k = mkTyVarTy kv
a:b:_ = tyVarList k
[a,b] = mkTemplateTyVars [k,k]
args = [kv, a, b]
coercibleClass :: Class
coercibleClass = mkClass (tyConTyVars coercibleTyCon) [] [] [] [] [] (mkAnd []) coercibleTyCon
{-
Note [The Implicit Parameter class]
Implicit parameters `?x :: a` are desugared into dictionaries for the
class `IP "x" a`, which is defined (in GHC.Classes) as
class IP (x :: Symbol) a | x -> a
This class is wired-in so that `error` and `undefined`, which have
wired-in types, can use the implicit-call-stack feature to provide
a call-stack alongside the error message.
-}
ipDataConName, ipTyConName, ipCoName :: Name
ipDataConName = mkWiredInDataConName UserSyntax gHC_CLASSES (fsLit "IP")
ipDataConKey ipDataCon
ipTyConName = mkWiredInTyConName UserSyntax gHC_CLASSES (fsLit "IP")
ipTyConKey ipTyCon
ipCoName = mkWiredInCoAxiomName BuiltInSyntax gHC_CLASSES (fsLit "NTCo:IP")
ipCoNameKey (toBranchedAxiom ipCoAxiom)
-- See Note [The Implicit Parameter class]
ipTyCon :: TyCon
ipTyCon = mkClassTyCon ipTyConName kind [ip,a] [] rhs ipClass NonRecursive
where
kind = mkArrowKinds [typeSymbolKind, liftedTypeKind] constraintKind
[ip,a] = mkTemplateTyVars [typeSymbolKind, liftedTypeKind]
rhs = NewTyCon ipDataCon (mkTyVarTy a) ([], mkTyVarTy a) ipCoAxiom
ipCoAxiom :: CoAxiom Unbranched
ipCoAxiom = mkNewTypeCo ipCoName ipTyCon [ip,a] [Nominal, Nominal] (mkTyVarTy a)
where
[ip,a] = mkTemplateTyVars [typeSymbolKind, liftedTypeKind]
ipDataCon :: DataCon
ipDataCon = pcDataCon ipDataConName [ip,a] ts ipTyCon
where
[ip,a] = mkTemplateTyVars [typeSymbolKind, liftedTypeKind]
ts = [mkTyVarTy a]
ipClass :: Class
ipClass = mkClass (tyConTyVars ipTyCon) [([ip], [a])] [] [] [] [] (mkAnd [])
ipTyCon
where
[ip, a] = tyConTyVars ipTyCon
-- this is a fake version of the CallStack TyCon so we can refer to it
-- in MkCore.errorTy
callStackTyCon :: TyCon
callStackTyCon = pcNonRecDataTyCon callStackTyConName Nothing [] []
......@@ -37,6 +37,7 @@ import FamInst( tcGetFamInstEnvs )
import TyCon
import TcType
import TysPrim
import TysWiredIn
import Id
import Var
import VarSet
......@@ -56,7 +57,7 @@ import BasicTypes
import Outputable
import FastString
import Type(mkStrLitTy)
import PrelNames( ipClassName, gHC_PRIM )
import PrelNames( gHC_PRIM )
import TcValidity (checkValidType)
import Control.Monad
......@@ -225,8 +226,7 @@ tcLocalBinds (HsValBinds (ValBindsOut binds sigs)) thing_inside
tcLocalBinds (HsValBinds (ValBindsIn {})) _ = panic "tcLocalBinds"
tcLocalBinds (HsIPBinds (IPBinds ip_binds _)) thing_inside
= do { ipClass <- tcLookupClass ipClassName
; (given_ips, ip_binds') <-
= do { (given_ips, ip_binds') <-
mapAndUnzipM (wrapLocSndM (tc_ip_bind ipClass)) ip_binds
-- If the binding binds ?x = E, we must now
......
......@@ -46,7 +46,7 @@ import Var
import VarSet
import VarEnv
import TysWiredIn
import TysPrim( intPrimTy, addrPrimTy )
import TysPrim( intPrimTy )
import PrimOp( tagToEnumKey )
import PrelNames
import DynFlags
......@@ -191,7 +191,6 @@ tcExpr (NegApp expr neg_expr) res_ty
tcExpr (HsIPVar x) res_ty
= do { let origin = IPOccOrigin x
; ipClass <- tcLookupClass ipClassName
{- Implicit parameters must have a *tau-type* not a.
type scheme. We enforce this by creating a fresh
type variable as its type. (Because res_ty may not
......@@ -1067,25 +1066,19 @@ tcInferIdWithOrig orig id_name
= do { dflags <- getDynFlags
; if gopt Opt_IgnoreAsserts dflags
then tc_infer_id orig id_name
else tc_infer_assert dflags orig }
else tc_infer_assert orig }
| otherwise
= tc_infer_id orig id_name
tc_infer_assert :: DynFlags -> CtOrigin -> TcM (HsExpr TcId, TcRhoType)
tc_infer_assert :: CtOrigin -> TcM (HsExpr TcId, TcRhoType)
-- Deal with an occurrence of 'assert'
-- See Note [Adding the implicit parameter to 'assert']
tc_infer_assert dflags orig
= do { sloc <- getSrcSpanM
; assert_error_id <- tcLookupId assertErrorName
tc_infer_assert orig
= do { assert_error_id <- tcLookupId assertErrorName
; (wrap, id_rho) <- deeplyInstantiate orig (idType assert_error_id)
; let (arg_ty, res_ty) = case tcSplitFunTy_maybe id_rho of
Nothing -> pprPanic "assert type" (ppr id_rho)
Just arg_res -> arg_res
; ASSERT( arg_ty `tcEqType` addrPrimTy )
return (HsApp (L sloc (mkHsWrap wrap (HsVar assert_error_id)))
(L sloc (srcSpanPrimLit dflags sloc))
, res_ty) }
; return (mkHsWrap wrap (HsVar assert_error_id), id_rho)
}
tc_infer_id :: CtOrigin -> Name -> TcM (HsExpr TcId, TcRhoType)
-- Return type is deeply instantiated
......@@ -1133,17 +1126,12 @@ tc_infer_id orig id_name
| isNaughtyRecordSelector id = failWithTc (naughtyRecordSel id)
| otherwise = return ()
srcSpanPrimLit :: DynFlags -> SrcSpan -> HsExpr TcId
srcSpanPrimLit dflags span
= HsLit (HsStringPrim "" (unsafeMkByteString
(showSDocOneLine dflags (ppr span))))
{-
Note [Adding the implicit parameter to 'assert']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The typechecker transforms (assert e1 e2) to (assertError "Foo.hs:27"
e1 e2). This isn't really the Right Thing because there's no way to
"undo" if you want to see the original source code in the typechecker
The typechecker transforms (assert e1 e2) to (assertError e1 e2).
This isn't really the Right Thing because there's no way to "undo"
if you want to see the original source code in the typechecker
output. We'll have fix this in due course, when we care more about
being able to reconstruct the exact original program.
......
......@@ -72,7 +72,7 @@ import Util
import Data.Maybe( isNothing )
import Control.Monad ( unless, when, zipWithM )
import PrelNames( ipClassName, funTyConKey, allNameStrings )
import PrelNames( funTyConKey, allNameStrings )
{-
----------------------------
......@@ -490,7 +490,6 @@ tc_hs_type hs_ty@(HsExplicitTupleTy _ tys) exp_kind
tc_hs_type ipTy@(HsIParamTy n ty) exp_kind
= do { ty' <- tc_lhs_type ty ekLifted
; checkExpectedKind ipTy constraintKind exp_kind
; ipClass <- tcLookupClass ipClassName
; let n' = mkStrLitTy $ hsIPNameFS n
; return (mkClassPred ipClass [n',ty'])
}
......
......@@ -20,9 +20,9 @@ import CoAxiom(sfInteractTop, sfInteractInert)
import Var
import TcType
import PrelNames ( knownNatClassName, knownSymbolClassName, ipClassNameKey,
import PrelNames ( knownNatClassName, knownSymbolClassName,
callStackTyConKey, typeableClassName )
import TysWiredIn ( typeNatKind, typeSymbolKind )
import TysWiredIn ( ipClass, typeNatKind, typeSymbolKind )
import Id( idType )
import Class
import TyCon
......@@ -704,7 +704,7 @@ interactDict inerts workItem@(CDictCan { cc_ev = ev_w, cc_class = cls, cc_tyargs
else
continueWith workItem }
| cls `hasKey` ipClassNameKey
| cls == ipClass
, isGiven ev_w
= interactGivenIP inerts workItem
......@@ -1755,7 +1755,7 @@ Other notes:
-- i.e. (IP "name" CallStack)
isCallStackIP :: CtLoc -> Class -> [Type] -> Maybe (EvTerm -> EvCallStack)
isCallStackIP loc cls tys
| cls `hasKey` ipClassNameKey
| cls == ipClass
, [_ip_name, ty] <- tys
, Just (tc, _) <- splitTyConApp_maybe ty
, tc `hasKey` callStackTyConKey
......
......@@ -29,7 +29,7 @@ import TysWiredIn ( typeNatKind, typeSymbolKind
, promotedEQDataCon
, promotedGTDataCon
)
import TysPrim ( tyVarList, mkArrowKinds )
import TysPrim ( mkArrowKinds, mkTemplateTyVars )
import PrelNames ( gHC_TYPELITS
, typeNatAddTyFamNameKey
, typeNatMulTyFamNameKey
......@@ -106,7 +106,7 @@ typeNatLeqTyCon :: TyCon
typeNatLeqTyCon =
mkFamilyTyCon name
(mkArrowKinds [ typeNatKind, typeNatKind ] boolKind)
(take 2 $ tyVarList typeNatKind)
(mkTemplateTyVars [ typeNatKind, typeNatKind ])
(BuiltInSynFamTyCon ops)
NoParentTyCon
......@@ -123,7 +123,7 @@ typeNatCmpTyCon :: TyCon
typeNatCmpTyCon =
mkFamilyTyCon name
(mkArrowKinds [ typeNatKind, typeNatKind ] orderingKind)
(take 2 $ tyVarList typeNatKind)
(mkTemplateTyVars [ typeNatKind, typeNatKind ])
(BuiltInSynFamTyCon ops)
NoParentTyCon
......@@ -140,7 +140,7 @@ typeSymbolCmpTyCon :: TyCon
typeSymbolCmpTyCon =
mkFamilyTyCon name
(mkArrowKinds [ typeSymbolKind, typeSymbolKind ] orderingKind)
(take 2 $ tyVarList typeSymbolKind)
(mkTemplateTyVars [ typeSymbolKind, typeSymbolKind ])
(BuiltInSynFamTyCon ops)
NoParentTyCon
......@@ -162,7 +162,7 @@ mkTypeNatFunTyCon2 :: Name -> BuiltInSynFamily -> TyCon
mkTypeNatFunTyCon2 op tcb =
mkFamilyTyCon op
(mkArrowKinds [ typeNatKind, typeNatKind ] typeNatKind)
(take 2 $ tyVarList typeNatKind)
(mkTemplateTyVars [ typeNatKind, typeNatKind ])
(BuiltInSynFamTyCon tcb)
NoParentTyCon
......
......@@ -163,7 +163,7 @@ import TyCon
import TysPrim
import {-# SOURCE #-} TysWiredIn ( eqTyCon, coercibleTyCon, typeNatKind, typeSymbolKind )
import PrelNames ( eqTyConKey, coercibleTyConKey,
ipClassNameKey, openTypeKindTyConKey,
ipTyConKey, openTypeKindTyConKey,
constraintKindTyConKey, liftedTypeKindTyConKey )
import CoAxiom
......@@ -908,10 +908,10 @@ isIPPred ty = case tyConAppTyCon_maybe ty of
_ -> False
isIPTyCon :: TyCon -> Bool
isIPTyCon tc = tc `hasKey` ipClassNameKey
isIPTyCon tc = tc `hasKey` ipTyConKey
isIPClass :: Class -> Bool
isIPClass cls = cls `hasKey` ipClassNameKey
isIPClass cls = cls `hasKey` ipTyConKey
-- Class and it corresponding TyCon have the same Unique
isCTupleClass :: Class -> Bool
......
......@@ -703,7 +703,7 @@ pprTyTcApp :: TyPrec -> TyCon -> [Type] -> SDoc
-- Used for types only; so that we can make a
-- special case for type-level lists
pprTyTcApp p tc tys
| tc `hasKey` ipClassNameKey
| tc `hasKey` ipTyConKey
, [LitTy (StrTyLit n),ty] <- tys
= maybeParen p FunPrec $
char '?' <> ftext n <> ptext (sLit "::") <> ppr_type TopPrec ty
......
......@@ -46,8 +46,8 @@
</listitem>
<listitem>
<para>
Implicit parameters of the new base type
<literal>GHC.Stack.CallStack</literal> are treated
Implicit parameters of the new ghc-prim type
<literal>GHC.Types.CallStack</literal> are treated
specially, and automatically solved for the current source
location. For example
<programlisting>
......@@ -66,7 +66,7 @@
parameter does not matter.
</para>
<para>
See the release notes for base for a description of the
See the release notes for ghc-prim for a description of the
<literal>CallStack</literal> type.
</para>
</listitem>
......@@ -249,19 +249,16 @@
</listitem>
<listitem>
<para>
A new module <literal>GHC.SrcLoc</literal> was added,
exporting a new type <literal>SrcLoc</literal>. A
<literal>SrcLoc</literal> contains package, module,
and file names, as well as start and end positions.
The functions <literal>error</literal>,
<literal>undefined</literal>, and
<literal>assertError</literal> now take an implicit
<literal>CallStack</literal> parameter, and will
output a formatted call stack alongside the error
message.
</para>
</listitem>
<listitem>
<para>
A new type <literal>CallStack</literal> was added for use
with the new implicit callstack parameters. A
<literal>CallStack</literal> is a
<literal>[(String, SrcLoc)]</literal>, sorted by most-recent
call.
See <xref linkend="implicit-parameters-special"/> for a description of the
implicit call stack feature.
</para>
</listitem>
<listitem>
......@@ -400,6 +397,22 @@
Version number XXXXX (was 0.3.1.0)
</para>
</listitem>
<listitem>
<para>
A new type <literal>SrcLoc</literal> was added. A
<literal>SrcLoc</literal> contains package, module,
and file names, as well as start and end positions.
</para>
</listitem>
<listitem>