Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anselm Schüler
GHC
Commits
e0b93c02
Commit
e0b93c02
authored
16 years ago
by
chak@cse.unsw.edu.au.
Browse files
Options
Downloads
Patches
Plain Diff
Fix for 1st half of #2203
parent
af97da87
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compiler/typecheck/TcMType.lhs
+19
-15
19 additions, 15 deletions
compiler/typecheck/TcMType.lhs
with
19 additions
and
15 deletions
compiler/typecheck/TcMType.lhs
+
19
−
15
View file @
e0b93c02
...
...
@@ -1486,22 +1486,26 @@ checkValidInstHead ty -- Should be a source type
check_inst_head :: DynFlags -> Class -> [Type] -> TcM ()
check_inst_head dflags clas tys
-- If GlasgowExts then check at least one isn't a type variable
= do checkTc (dopt Opt_TypeSynonymInstances dflags ||
all tcInstHeadTyNotSynonym tys)
(instTypeErr (pprClassPred clas tys) head_type_synonym_msg)
checkTc (dopt Opt_FlexibleInstances dflags ||
all tcInstHeadTyAppAllTyVars tys)
(instTypeErr (pprClassPred clas tys) head_type_args_tyvars_msg)
checkTc (dopt Opt_MultiParamTypeClasses dflags ||
isSingleton tys)
(instTypeErr (pprClassPred clas tys) head_one_type_msg)
mapM_ check_mono_type tys
= do { -- If GlasgowExts then check at least one isn't a type variable
; checkTc (dopt Opt_TypeSynonymInstances dflags ||
all tcInstHeadTyNotSynonym tys)
(instTypeErr (pprClassPred clas tys) head_type_synonym_msg)
; checkTc (dopt Opt_FlexibleInstances dflags ||
all tcInstHeadTyAppAllTyVars tys)
(instTypeErr (pprClassPred clas tys) head_type_args_tyvars_msg)
; checkTc (dopt Opt_MultiParamTypeClasses dflags ||
isSingleton tys)
(instTypeErr (pprClassPred clas tys) head_one_type_msg)
-- May not contain type family applications
; mapM_ checkTyFamFreeness tys
; mapM_ check_mono_type tys
-- For now, I only allow tau-types (not polytypes) in
-- the head of an instance decl.
-- E.g. instance C (forall a. a->a) is rejected
-- One could imagine generalising that, but I'm not sure
-- what all the consequences might be
}
where
head_type_synonym_msg = parens (
...
...
@@ -1719,7 +1723,7 @@ checkFamInst lhsTys famInsts
checkTyFamFreeness :: Type -> TcM ()
checkTyFamFreeness ty
= checkTc (isTyFamFree ty) $
tyFamInstI
nIndex
Err ty
tyFamInstI
llegal
Err ty
-- Check that a type does not contain any type family applications.
--
...
...
@@ -1728,9 +1732,9 @@ isTyFamFree = null . tyFamInsts
-- Error messages
tyFamInstI
nIndex
Err :: Type -> SDoc
tyFamInstI
nIndex
Err ty
= hang (ptext (sLit "Illegal type family application in
type
instance") <>
tyFamInstI
llegal
Err :: Type -> SDoc
tyFamInstI
llegal
Err ty
= hang (ptext (sLit "Illegal type
synonym
family application in instance") <>
colon) 4 $
ppr ty
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment