diff options
author | simonpj <unknown> | 2001-03-13 14:58:28 +0000 |
---|---|---|
committer | simonpj <unknown> | 2001-03-13 14:58:28 +0000 |
commit | 788faebb40b51d37e73ed94dfc99460d39a1a811 (patch) | |
tree | 5aed135958315fcb297c1c4908440775fdbdf1ad /ghc/compiler/rename | |
parent | 6a44ce76861d73d59badc8f8c17ffbd52eff17ba (diff) | |
download | haskell-788faebb40b51d37e73ed94dfc99460d39a1a811.tar.gz |
[project @ 2001-03-13 14:58:25 by simonpj]
----------------
Nuke ClassContext
----------------
This commit tidies up a long-standing inconsistency in GHC.
The context of a class or instance decl used to be restricted
to predicates of the form
C t1 .. tn
with
type ClassContext = [(Class,[Type])]
but everywhere else in the compiler we used
type ThetaType = [PredType]
where PredType can be any sort of constraint (= predicate).
The inconsistency actually led to a crash, when compiling
class (?x::Int) => C a where {}
I've tidied all this up by nuking ClassContext altogether, and using
PredType throughout. Lots of modified files, but all in
more-or-less trivial ways.
I've also added a check that the context of a class or instance
decl doesn't include a non-inheritable predicate like (?x::Int).
Other things
* rename constructor 'Class' from type TypeRep.Pred to 'ClassP'
(makes it easier to grep for)
* rename constructor HsPClass => HsClassP
HsPIParam => HsIParam
Diffstat (limited to 'ghc/compiler/rename')
-rw-r--r-- | ghc/compiler/rename/ParseIface.y | 4 | ||||
-rw-r--r-- | ghc/compiler/rename/RnHsSyn.lhs | 4 | ||||
-rw-r--r-- | ghc/compiler/rename/RnSource.lhs | 12 |
3 files changed, 10 insertions, 10 deletions
diff --git a/ghc/compiler/rename/ParseIface.y b/ghc/compiler/rename/ParseIface.y index 7fa4cd352e..e4bcf4b67f 100644 --- a/ghc/compiler/rename/ParseIface.y +++ b/ghc/compiler/rename/ParseIface.y @@ -524,8 +524,8 @@ context_list1 : class { [$1] } | class ',' context_list1 { $1 : $3 } class :: { HsPred RdrName } -class : qcls_name atypes { (HsPClass $1 $2) } - | ipvar_name '::' type { (HsPIParam $1 $3) } +class : qcls_name atypes { (HsClassP $1 $2) } + | ipvar_name '::' type { (HsIParam $1 $3) } types0 :: { [RdrNameHsType] {- Zero or more -} } types0 : {- empty -} { [ ] } diff --git a/ghc/compiler/rename/RnHsSyn.lhs b/ghc/compiler/rename/RnHsSyn.lhs index 04531edfdd..80627db4c3 100644 --- a/ghc/compiler/rename/RnHsSyn.lhs +++ b/ghc/compiler/rename/RnHsSyn.lhs @@ -97,9 +97,9 @@ extractHsCtxtTyNames ctxt = foldr (unionNameSets . extractHsPredTyNames) emptyNa -- You don't import or export implicit parameters, -- so don't mention the IP names -extractHsPredTyNames (HsPClass cls tys) +extractHsPredTyNames (HsClassP cls tys) = unitNameSet cls `unionNameSets` extractHsTyNames_s tys -extractHsPredTyNames (HsPIParam n ty) +extractHsPredTyNames (HsIParam n ty) = extractHsTyNames ty \end{code} diff --git a/ghc/compiler/rename/RnSource.lhs b/ghc/compiler/rename/RnSource.lhs index fe24db11ab..491e4bf116 100644 --- a/ghc/compiler/rename/RnSource.lhs +++ b/ghc/compiler/rename/RnSource.lhs @@ -651,19 +651,19 @@ rnContext doc ctxt (naughtyCCallContextErr pred') `thenRn_` returnRn pred' - bad_pred (HsPClass clas _) = getUnique clas `elem` cCallishClassKeys + bad_pred (HsClassP clas _) = getUnique clas `elem` cCallishClassKeys bad_pred other = False -rnPred doc (HsPClass clas tys) +rnPred doc (HsClassP clas tys) = lookupOccRn clas `thenRn` \ clas_name -> rnHsTypes doc tys `thenRn` \ tys' -> - returnRn (HsPClass clas_name tys') + returnRn (HsClassP clas_name tys') -rnPred doc (HsPIParam n ty) +rnPred doc (HsIParam n ty) = newIPName n `thenRn` \ name -> rnHsType doc ty `thenRn` \ ty' -> - returnRn (HsPIParam name ty') + returnRn (HsIParam name ty') \end{code} \begin{code} @@ -893,7 +893,7 @@ dupClassAssertWarn ctxt (assertion : dups) ptext SLIT("in the context:")], nest 4 (pprHsContext ctxt <+> ptext SLIT("..."))] -naughtyCCallContextErr (HsPClass clas _) +naughtyCCallContextErr (HsClassP clas _) = sep [ptext SLIT("Can't use class") <+> quotes (ppr clas), ptext SLIT("in a context")] \end{code} |