diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-04-22 01:01:06 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-05-08 15:29:36 -0400 |
commit | 20570b4b5e741912d1dc3f1826ee1f78e33f3b90 (patch) | |
tree | 5714766374c22d6b2eff2b547b9caefeb4ea32ef | |
parent | f4d5c6df56a28be5448acf43e4f45b1695ae9eb5 (diff) | |
download | haskell-20570b4b5e741912d1dc3f1826ee1f78e33f3b90.tar.gz |
A few tiny style nits with renaming
- Use case rather than guards that repeatedly scrutenize same thing.
- No need for view pattern when `L` is fine.
- Use type synnonym to convey the intent like elsewhere.
-rw-r--r-- | compiler/GHC/Rename/HsType.hs | 14 | ||||
-rw-r--r-- | compiler/GHC/Rename/Module.hs | 5 |
2 files changed, 10 insertions, 9 deletions
diff --git a/compiler/GHC/Rename/HsType.hs b/compiler/GHC/Rename/HsType.hs index 144534f4ec..ab25334938 100644 --- a/compiler/GHC/Rename/HsType.hs +++ b/compiler/GHC/Rename/HsType.hs @@ -1628,7 +1628,7 @@ extractHsTyRdrTyVarsDups ty -- Note [Ordering of implicit variables] and -- Note [Implicit quantification in type synonyms]. extractHsTyRdrTyVarsKindVars :: LHsType GhcPs -> FreeKiTyVarsNoDups -extractHsTyRdrTyVarsKindVars (unLoc -> ty) = +extractHsTyRdrTyVarsKindVars (L _ ty) = case ty of HsParTy _ ty -> extractHsTyRdrTyVarsKindVars ty HsKindSig _ _ ki -> extractHsTyRdrTyVars ki @@ -1656,12 +1656,12 @@ extractHsTyVarBndrsKVs tv_bndrs -- variable occurrences in left-to-right order. -- See Note [Ordering of implicit variables]. extractRdrKindSigVars :: LFamilyResultSig GhcPs -> [Located RdrName] -extractRdrKindSigVars (L _ resultSig) - | KindSig _ k <- resultSig = extractHsTyRdrTyVars k - | TyVarSig _ (L _ (KindedTyVar _ _ k)) <- resultSig = extractHsTyRdrTyVars k - | otherwise = [] +extractRdrKindSigVars (L _ resultSig) = case resultSig of + KindSig _ k -> extractHsTyRdrTyVars k + TyVarSig _ (L _ (KindedTyVar _ _ k)) -> extractHsTyRdrTyVars k + _ -> [] --- Get type/kind variables mentioned in the kind signature, preserving +-- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order and without duplicates: -- -- * data T a (b :: k1) :: k2 -> k1 -> k2 -> Type -- result: [k2,k1] @@ -1744,7 +1744,7 @@ extract_hs_tv_bndrs tv_bndrs acc_vars body_vars bndr_vars = extract_hs_tv_bndrs_kvs tv_bndrs tv_bndr_rdrs = map hsLTyVarLocName tv_bndrs -extract_hs_tv_bndrs_kvs :: [LHsTyVarBndr GhcPs] -> [Located RdrName] +extract_hs_tv_bndrs_kvs :: [LHsTyVarBndr GhcPs] -> FreeKiTyVarsWithDups -- Returns the free kind variables of any explicitly-kinded binders, returning -- variable occurrences in left-to-right order. -- See Note [Ordering of implicit variables]. diff --git a/compiler/GHC/Rename/Module.hs b/compiler/GHC/Rename/Module.hs index 10a707c9ee..346a1cae99 100644 --- a/compiler/GHC/Rename/Module.hs +++ b/compiler/GHC/Rename/Module.hs @@ -683,8 +683,9 @@ rnFamInstEqn doc atfi rhs_kvars -- Implicitly bound variables, empty if we have an explicit 'forall' according -- to the "forall-or-nothing" rule. - ; let imp_vars | isNothing mb_bndrs = nubL pat_kity_vars_with_dups - | otherwise = [] + ; let imp_vars = case mb_bndrs of + Nothing -> nubL pat_kity_vars_with_dups + Just _ -> [] ; imp_var_names <- mapM (newTyVarNameRn mb_cls) imp_vars ; let bndrs = fromMaybe [] mb_bndrs |