Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
272fb49e
Commit
272fb49e
authored
Jan 10, 2007
by
chak@cse.unsw.edu.au.
Browse files
checkTauTvUpdate: take synonym families into account
parent
c4ff47ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
compiler/typecheck/TcType.lhs
View file @
272fb49e
...
...
@@ -560,8 +560,8 @@ isTauTy other = False
isTauTyCon :: TyCon -> Bool
-- Returns False for type synonyms whose expansion is a polytype
isTauTyCon tc
| is
SynTyCon tc && not (isOpe
nTyCon tc
)
= isTauTy (snd (synTyConDefn tc))
| otherwise
= True
| is
ClosedSy
nTyCon tc = isTauTy (snd (synTyConDefn tc))
| otherwise = True
---------------
isBoxyTy :: TcType -> Bool
...
...
compiler/typecheck/TcUnify.lhs
View file @
272fb49e
...
...
@@ -1366,7 +1366,11 @@ checkTauTvUpdate orig_tv orig_ty
; case mb_tys' of
Just tys' -> return (TyConApp tc tys')
-- Retain the synonym (the common case)
Nothing -> go (expectJust "checkTauTvUpdate"
Nothing | isOpenTyCon tc
-> notMonoArgs (TyConApp tc tys)
-- Synonym families must have monotype args
| otherwise
-> go (expectJust "checkTauTvUpdate"
(tcView (TyConApp tc tys)))
-- Try again, expanding the synonym
}
...
...
@@ -1588,6 +1592,13 @@ notMonoType ty
msg = ptext SLIT("Cannot match a monotype with") <+> quotes (ppr tidy_ty)
; failWithTcM (env1, msg) }
notMonoArgs ty
= do { ty' <- zonkTcType ty
; env0 <- tcInitTidyEnv
; let (env1, tidy_ty) = tidyOpenType env0 ty'
msg = ptext SLIT("Arguments of synonym family must be monotypes") <+> quotes (ppr tidy_ty)
; failWithTcM (env1, msg) }
occurCheck tyvar ty
= do { env0 <- tcInitTidyEnv
; ty' <- zonkTcType ty
...
...
compiler/types/TyCon.lhs
View file @
272fb49e
...
...
@@ -17,8 +17,8 @@ module TyCon(
SynTyConRhs(..),
isFunTyCon, isUnLiftedTyCon, isProductTyCon,
isAlgTyCon, isDataTyCon,
isSynTyCon,
isNewTyCon, isClosedNewTyCon,
isPrimTyCon,
isAlgTyCon, isDataTyCon, isNewTyCon, isClosedNewTyCon,
isSynTyCon,
isClosedSynTyCon,
isPrimTyCon,
isEnumerationTyCon, isGadtSyntaxTyCon, isOpenTyCon,
assocTyConArgPoss_maybe, isTyConAssoc, setTyConArgPoss,
isTupleTyCon, isUnboxedTupleTyCon, isBoxedTupleTyCon, tupleTyConBoxity,
...
...
@@ -600,6 +600,13 @@ isSynTyCon :: TyCon -> Bool
isSynTyCon (SynTyCon {}) = True
isSynTyCon _ = False
-- As for newtypes, it is in some contexts important to distinguish between
-- closed synonyms and synonym families, as synonym families have no unique
-- right hand side to which a synonym family application can expand.
--
isClosedSynTyCon :: TyCon -> Bool
isClosedSynTyCon tycon = isSynTyCon tycon && not (isOpenTyCon tycon)
isGadtSyntaxTyCon :: TyCon -> Bool
isGadtSyntaxTyCon (AlgTyCon { algTcGadtSyntax = res }) = res
isGadtSyntaxTyCon other = False
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment