diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2014-06-24 22:19:24 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2014-06-27 09:16:42 +0100 |
commit | 0451f9137a73777170cd797406a1afb67cfb8916 (patch) | |
tree | 0b0c464b5f9b56fd9d17a1b7b76870d1b2bc8819 /compiler/types/Type.lhs | |
parent | af913ad24afda66762bc05949dc50bcd01da257d (diff) | |
download | haskell-0451f9137a73777170cd797406a1afb67cfb8916.tar.gz |
More allDistinctTyVars from TcDeriv to Type
Just a minor refactoring
Diffstat (limited to 'compiler/types/Type.lhs')
-rw-r--r-- | compiler/types/Type.lhs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs index 808216f2ef..55df643285 100644 --- a/compiler/types/Type.lhs +++ b/compiler/types/Type.lhs @@ -36,7 +36,7 @@ module Type ( mkForAllTy, mkForAllTys, splitForAllTy_maybe, splitForAllTys, mkPiKinds, mkPiType, mkPiTypes, - applyTy, applyTys, applyTysD, isForAllTy, dropForAlls, + applyTy, applyTys, applyTysD, dropForAlls, mkNumLitTy, isNumLitTy, mkStrLitTy, isStrLitTy, @@ -63,7 +63,7 @@ module Type ( funTyCon, -- ** Predicates on types - isTypeVar, isKindVar, + isTypeVar, isKindVar, allDistinctTyVars, isForAllTy, isTyVarTy, isFunTy, isDictTy, isPredTy, isVoidTy, -- (Lifting and boxity) @@ -323,6 +323,15 @@ getTyVar_maybe ty | Just ty' <- coreView ty = getTyVar_maybe ty' getTyVar_maybe (TyVarTy tv) = Just tv getTyVar_maybe _ = Nothing +allDistinctTyVars :: [KindOrType] -> Bool +allDistinctTyVars tkvs = go emptyVarSet tkvs + where + go _ [] = True + go so_far (ty : tys) + = case getTyVar_maybe ty of + Nothing -> False + Just tv | tv `elemVarSet` so_far -> False + | otherwise -> go (so_far `extendVarSet` tv) tys \end{code} |