diff options
author | Ćukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-07-17 18:51:04 +0200 |
---|---|---|
committer | Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> | 2015-08-21 18:22:30 +0100 |
commit | 1633853280a22aa1ddf682465eedaa1cf3b6905a (patch) | |
tree | 794e977a63d62c42882e2ab97da1c897b5258b2e /haddock-api | |
parent | 51e145b013380965db7fe2a9983a3064cde57eb9 (diff) |
Remove code duplication in specialized type renamer.
Diffstat (limited to 'haddock-api')
-rw-r--r-- | haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs index c59dd2c8..a7b7a561 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs @@ -135,9 +135,9 @@ renameType (HsBangTy bang lt) = HsBangTy bang <$> renameLType lt renameType t@(HsRecTy _) = pure t renameType t@(HsCoreTy _) = pure t renameType (HsExplicitListTy ph ltys) = - HsExplicitListTy ph <$> mapM renameLType ltys + HsExplicitListTy ph <$> renameLTypes ltys renameType (HsExplicitTupleTy phs ltys) = - HsExplicitTupleTy phs <$> mapM renameLType ltys + HsExplicitTupleTy phs <$> renameLTypes ltys renameType t@(HsTyLit _) = pure t renameType (HsWrapTy wrap t) = HsWrapTy wrap <$> renameType t renameType HsWildcardTy = pure HsWildcardTy @@ -148,16 +148,20 @@ renameLType :: Ord name => LHsType name -> Rename name (LHsType name) renameLType = located renameType +renameLTypes :: Ord name => [LHsType name] -> Rename name [LHsType name] +renameLTypes = mapM renameLType + + +renameContext :: Ord name => HsContext name -> Rename name (HsContext name) +renameContext = renameLTypes + + renameLTyVarBndrs :: Ord name => LHsTyVarBndrs name -> Rename name (LHsTyVarBndrs name) renameLTyVarBndrs lbndrs = do tys' <- mapM (located renameTyVarBndr) $ hsq_tvs lbndrs pure $ lbndrs { hsq_tvs = tys' } -renameContext :: Ord name => HsContext name -> Rename name (HsContext name) -renameContext = mapM $ located renameType - - renameTyVarBndr :: Ord name => HsTyVarBndr name -> Rename name (HsTyVarBndr name) renameTyVarBndr (UserTyVar name) = UserTyVar <$> renameNameBndr name |