From 1633853280a22aa1ddf682465eedaa1cf3b6905a Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Fri, 17 Jul 2015 18:51:04 +0200 Subject: Remove code duplication in specialized type renamer. --- haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'haddock-api') 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 -- cgit v1.2.3