@@ -41,6 +41,7 @@ data AugmentType
4141 -- ^ Augment documentation for a type class
4242 | AugmentType
4343 -- ^ Augment documentation for a type constructor
44+ deriving (Show )
4445
4546-- | The data type for an intermediate stage which we go through during
4647-- converting.
@@ -82,23 +83,25 @@ augmentDeclarations (partitionEithers -> (augments, toplevels)) =
8283 where
8384 go ds (parentTitles, a) =
8485 map (\ d ->
85- if any (matches d) parentTitles
86- then augmentWith a d
87- else d) ds
86+ case find (matches d) ( Tr. traceShow ( parentTitles) parentTitles) of
87+ Just match -> Tr. traceShow match $ augmentWith match a d
88+ Nothing -> d) ds
8889
8990 matches d (name, AugmentType ) = isType d && declTitle d == name
9091 matches d (name, AugmentClass ) = isTypeClass d && declTitle d == name
9192
92- augmentWith (AugmentChild child) d =
93+ augmentWith _ (AugmentChild child) d =
9394 d { declChildren = declChildren d ++ [child] }
94- augmentWith (AugmentChain chainId instanceChainInfo) d =
95- d {declChildren = augmentChildInstance chainId instanceChainInfo (declChildren d) }
95+ augmentWith (_, AugmentClass ) (AugmentChain chainId instanceChainInfo) d =
96+ d { declChildren = augmentChildInstance chainId instanceChainInfo (declChildren d) }
97+ augmentWith (_, AugmentType ) (AugmentChain chainId instanceChainInfo) d =
98+ d { declChildren = declChildren d ++ [ChildDeclaration (titleForInstanceChain chainId) Nothing Nothing (ChildPartOfInstanceChain instanceChainInfo)]}
9699
97- titleForInstanceChain = T. intercalate " > "
100+ titleForInstanceChain = T. intercalate " -else- "
98101
99102 augmentChildInstance chainId instanceChainInfo [] = [ChildDeclaration (titleForInstanceChain chainId) Nothing Nothing (ChildInstanceChain [instanceChainInfo])]
100103 augmentChildInstance chainId instanceChainInfo (ChildDeclaration name comment span (ChildInstanceChain chain) : rest) =
101- if traceShow ( " compare " , chainId, name) ( titleForInstanceChain chainId == name) then
104+ if titleForInstanceChain chainId == name then
102105 (ChildDeclaration name comment span (ChildInstanceChain (chain ++ [instanceChainInfo])) : rest)
103106 else
104107 (ChildDeclaration name comment span (ChildInstanceChain chain) : augmentChildInstance chainId instanceChainInfo rest)
@@ -160,7 +163,7 @@ convertDeclaration (P.TypeClassDeclaration sa _ args implies fundeps ds) title =
160163 ChildDeclaration (P. showIdent ident') (convertComments com) (Just ss) (ChildTypeClassMember (ty $> () ))
161164 convertClassMember _ =
162165 P. internalError " convertDeclaration: Invalid argument to convertClassMember."
163- convertDeclaration (P. TypeInstanceDeclaration (ss, com) instanceChain idx ident constraints className tys _) title =
166+ convertDeclaration (P. TypeInstanceDeclaration (ss, com) instanceChain _ _ constraints className tys _) title =
164167 Just (Left ((classNameString, AugmentClass ) : map (, AugmentType ) typeNameStrings, AugmentChain (P. runIdent <$> instanceChain) instanceChainDecl))
165168 where
166169 classNameString = unQual className
@@ -170,7 +173,7 @@ convertDeclaration (P.TypeInstanceDeclaration (ss, com) instanceChain idx ident
170173 extractProperNames (P. TypeConstructor _ n) = [unQual n]
171174 extractProperNames _ = []
172175
173- instanceChainDecl = ChildInstanceChainInfo ( Tr. traceShow ( " declaration " , title, P. runIdent <$> instanceChain) title) (convertComments com) (Just ss) (fmap ($> () ) constraints) (classApp $> () )
176+ instanceChainDecl = ChildInstanceChainInfo title (convertComments com) (Just ss) (fmap ($> () ) constraints) (classApp $> () )
174177
175178 classApp = foldl' P. srcTypeApp (P. srcTypeConstructor (fmap P. coerceProperName className)) tys
176179convertDeclaration (P. ValueFixityDeclaration sa fixity (P. Qualified mn alias) _) title =
0 commit comments