aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Interface
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2011-11-06 00:01:47 +0100
committerDavid Waern <david.waern@gmail.com>2011-11-06 00:01:47 +0100
commit2d0c63d4155fde1b5d8f51b66aa2393f265eaa7b (patch)
tree074f93a78bd3059e80cbfb1f1cd29aa5b960d340 /src/Haddock/Interface
parent0a8d2696f88e0308fd689475ce2896b6ba014694 (diff)
parent2deba11b49ed5ca29e947e875349f870310d3746 (diff)
Merge branch 'master' of http://darcs.haskell.org/haddock
Diffstat (limited to 'src/Haddock/Interface')
-rw-r--r--src/Haddock/Interface/AttachInstances.hs2
-rw-r--r--src/Haddock/Interface/Create.hs4
-rw-r--r--src/Haddock/Interface/ExtractFnArgDocs.hs2
-rw-r--r--src/Haddock/Interface/Rename.hs44
4 files changed, 16 insertions, 36 deletions
diff --git a/src/Haddock/Interface/AttachInstances.hs b/src/Haddock/Interface/AttachInstances.hs
index e4da3233..01d5b0f4 100644
--- a/src/Haddock/Interface/AttachInstances.hs
+++ b/src/Haddock/Interface/AttachInstances.hs
@@ -116,7 +116,6 @@ getAllInfo name = withSession $ \hsc_env -> do
data SimpleType = SimpleType Name [SimpleType] deriving (Eq,Ord)
--- TODO: should we support PredTy here?
instHead :: ([TyVar], [PredType], Class, [Type]) -> ([Int], Name, [SimpleType])
instHead (_, _, cls, args)
= (map argCount args, className cls, map simplify args)
@@ -134,7 +133,6 @@ instHead (_, _, cls, args)
where (SimpleType s ts) = simplify t1
simplify (TyVarTy v) = SimpleType (tyVarName v) []
simplify (TyConApp tc ts) = SimpleType (tyConName tc) (map simplify ts)
- simplify _ = error "simplify"
-- sortImage f = sortBy (\x y -> compare (f x) (f y))
diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs
index f9d72bd0..057fceb7 100644
--- a/src/Haddock/Interface/Create.hs
+++ b/src/Haddock/Interface/Create.hs
@@ -263,7 +263,7 @@ declsFromClass class_ = docs ++ defs ++ sigs ++ ats
declNames :: HsDecl a -> [a]
declNames (TyClD d) = [tcdName d]
-declNames (ForD (ForeignImport n _ _)) = [unLoc n]
+declNames (ForD (ForeignImport n _ _ _)) = [unLoc n]
-- we have normal sigs only (since they are taken from ValBindsOut)
declNames (SigD sig) = sigNameNoLoc sig
declNames _ = error "unexpected argument to declNames"
@@ -770,7 +770,7 @@ extractClassDecl c tvs0 (L pos (TypeSig lname ltype)) = case ltype of
_ -> L pos (TypeSig lname (noLoc (mkImplicitHsForAllTy (lctxt []) ltype)))
where
lctxt = noLoc . ctxt
- ctxt preds = noLoc (HsClassP c (map toTypeNoLoc tvs0)) : preds
+ ctxt preds = nlHsTyConApp c (map toTypeNoLoc tvs0) : preds
extractClassDecl _ _ _ = error "extractClassDecl: unexpected decl"
diff --git a/src/Haddock/Interface/ExtractFnArgDocs.hs b/src/Haddock/Interface/ExtractFnArgDocs.hs
index 8889c3ab..a9f8a807 100644
--- a/src/Haddock/Interface/ExtractFnArgDocs.hs
+++ b/src/Haddock/Interface/ExtractFnArgDocs.hs
@@ -24,7 +24,7 @@ import GHC
getDeclFnArgDocs :: HsDecl Name -> Map Int HsDocString
getDeclFnArgDocs (SigD (TypeSig _ ty)) = getTypeFnArgDocs ty
-getDeclFnArgDocs (ForD (ForeignImport _ ty _)) = getTypeFnArgDocs ty
+getDeclFnArgDocs (ForD (ForeignImport _ ty _ _)) = getTypeFnArgDocs ty
getDeclFnArgDocs (TyClD (TySynonym {tcdSynRhs = ty})) = getTypeFnArgDocs ty
getDeclFnArgDocs _ = Map.empty
diff --git a/src/Haddock/Interface/Rename.hs b/src/Haddock/Interface/Rename.hs
index 2d5c899a..546ba62b 100644
--- a/src/Haddock/Interface/Rename.hs
+++ b/src/Haddock/Interface/Rename.hs
@@ -17,8 +17,8 @@ import Haddock.GhcUtils
import GHC hiding (NoLink)
import Name
-import BasicTypes
import Bag (emptyBag)
+import BasicTypes ( IPName(..), ipNameName )
import Data.List
import qualified Data.Map as Map hiding ( Map )
@@ -208,25 +208,6 @@ renameFnArgsDoc :: FnArgsDoc Name -> RnM (FnArgsDoc DocName)
renameFnArgsDoc = mapM renameDoc
-renameLPred :: LHsPred Name -> RnM (LHsPred DocName)
-renameLPred = mapM renamePred
-
-
-renamePred :: HsPred Name -> RnM (HsPred DocName)
-renamePred (HsClassP name types) = do
- name' <- rename name
- types' <- mapM renameLType types
- return (HsClassP name' types')
-renamePred (HsEqualP type1 type2) = do
- type1' <- renameLType type1
- type2' <- renameLType type2
- return (HsEqualP type1' type2')
-renamePred (HsIParam (IPName name) t) = do
- name' <- rename name
- t' <- renameLType t
- return (HsIParam (IPName name') t')
-
-
renameLType :: LHsType Name -> RnM (LHsType DocName)
renameLType = mapM renameType
@@ -254,6 +235,8 @@ renameType t = case t of
HsListTy ty -> return . HsListTy =<< renameLType ty
HsPArrTy ty -> return . HsPArrTy =<< renameLType ty
+ HsIParamTy n ty -> liftM2 HsIParamTy (liftM IPName (rename (ipNameName n))) (renameLType ty)
+ HsEqTy ty1 ty2 -> liftM2 HsEqTy (renameLType ty1) (renameLType ty2)
HsTupleTy b ts -> return . HsTupleTy b =<< mapM renameLType ts
@@ -265,8 +248,6 @@ renameType t = case t of
HsParTy ty -> return . HsParTy =<< renameLType ty
- HsPredTy p -> return . HsPredTy =<< renamePred p
-
HsKindSig ty k -> do
ty' <- renameLType ty
return (HsKindSig ty' k)
@@ -285,15 +266,15 @@ renameLTyVarBndr (L loc tv) = do
return $ L loc (replaceTyVarName tv name')
-renameLContext :: Located [LHsPred Name] -> RnM (Located [LHsPred DocName])
+renameLContext :: Located [LHsType Name] -> RnM (Located [LHsType DocName])
renameLContext (L loc context) = do
- context' <- mapM renameLPred context
+ context' <- mapM renameLType context
return (L loc context')
renameInstHead :: InstHead Name -> RnM (InstHead DocName)
renameInstHead (preds, className, types) = do
- preds' <- mapM renamePred preds
+ preds' <- mapM renameType preds
className' <- rename className
types' <- mapM renameType types
return (preds', className', types')
@@ -351,15 +332,16 @@ renameTyClD d = case d of
typats' <- mapM (mapM renameLType) typats
return (TySynonym lname' ltyvars' typats' ltype')
- ClassDecl lcontext lname ltyvars lfundeps lsigs _ ats _ -> do
+ ClassDecl lcontext lname ltyvars lfundeps lsigs _ ats at_defs _ -> do
lcontext' <- renameLContext lcontext
lname' <- renameL lname
ltyvars' <- mapM renameLTyVarBndr ltyvars
lfundeps' <- mapM renameLFunDep lfundeps
lsigs' <- mapM renameLSig lsigs
ats' <- mapM renameLTyClD ats
+ at_defs' <- mapM renameLTyClD at_defs
-- we don't need the default methods or the already collected doc entities
- return (ClassDecl lcontext' lname' ltyvars' lfundeps' lsigs' emptyBag ats' [])
+ return (ClassDecl lcontext' lname' ltyvars' lfundeps' lsigs' emptyBag ats' at_defs' [])
where
renameLCon (L loc con) = return . L loc =<< renameCon con
@@ -410,14 +392,14 @@ renameSig sig = case sig of
renameForD :: ForeignDecl Name -> RnM (ForeignDecl DocName)
-renameForD (ForeignImport lname ltype x) = do
+renameForD (ForeignImport lname ltype co x) = do
lname' <- renameL lname
ltype' <- renameLType ltype
- return (ForeignImport lname' ltype' x)
-renameForD (ForeignExport lname ltype x) = do
+ return (ForeignImport lname' ltype' co x)
+renameForD (ForeignExport lname ltype co x) = do
lname' <- renameL lname
ltype' <- renameLType ltype
- return (ForeignExport lname' ltype' x)
+ return (ForeignExport lname' ltype' co x)
renameInstD :: InstDecl Name -> RnM (InstDecl DocName)