diff options
Diffstat (limited to 'compiler/GHC/Core/TyCon.hs')
-rw-r--r-- | compiler/GHC/Core/TyCon.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/GHC/Core/TyCon.hs b/compiler/GHC/Core/TyCon.hs index 4db3167bd7..efa6cfbcf7 100644 --- a/compiler/GHC/Core/TyCon.hs +++ b/compiler/GHC/Core/TyCon.hs @@ -2257,13 +2257,14 @@ expandSynTyCon_maybe -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application - --- ^ Expand a type synonym application, if any +-- ^ Expand a type synonym application +-- Return Nothing if the TyCon is not a synonym, +-- or if not enough arguments are supplied expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc - = case tys of - [] -> Just ([], rhs, []) -- Avoid a bit of work in the case of nullary synonyms - _ -> case tys `listLengthCmp` arity of + = if arity == 0 + then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + else case tys `listLengthCmp` arity of GT -> Just (tvs `zip` tys, rhs, drop arity tys) EQ -> Just (tvs `zip` tys, rhs, []) LT -> Nothing |