aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Backends/Xhtml/Decl.hs
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-02-19 05:11:34 +0000
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-02-19 05:11:34 +0000
commit91e2c21cfdaca7913dbfec17bdd7712c0c1ed732 (patch)
treeb8a93a633cedc924042300334748750e27b945cb /src/Haddock/Backends/Xhtml/Decl.hs
parent6b35adfb811d9e41e5bfa1c11963e441740c2836 (diff)
Use a bespoke data type to indicate fixity
This deals with what I imagine was an ancient TODO and makes it much clearer what the argument actually does rather than having the user chase down the comment.
Diffstat (limited to 'src/Haddock/Backends/Xhtml/Decl.hs')
-rw-r--r--src/Haddock/Backends/Xhtml/Decl.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Haddock/Backends/Xhtml/Decl.hs b/src/Haddock/Backends/Xhtml/Decl.hs
index 85eee248..72369069 100644
--- a/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/src/Haddock/Backends/Xhtml/Decl.hs
@@ -183,7 +183,7 @@ ppTypeSig summary nms pp_ty unicode =
ppTyName :: Name -> Html
-ppTyName = ppName (Just False)
+ppTyName = ppName Prefix
--------------------------------------------------------------------------------
@@ -273,7 +273,7 @@ ppDataBinderWithVars summ decl =
-- | Print an application of a DocName and two lists of HsTypes (kinds, types)
ppAppNameTypes :: DocName -> [HsType DocName] -> [HsType DocName] -> Bool -> Qualification -> Html
ppAppNameTypes n ks ts unicode qual =
- ppTypeApp n ks ts (ppDocName qual . Just) (ppParendType unicode qual)
+ ppTypeApp n ks ts (ppDocName qual) (ppParendType unicode qual)
-- | Print an application of a DocName and a list of Names
@@ -281,20 +281,20 @@ ppAppDocNameNames :: Bool -> DocName -> [Name] -> Html
ppAppDocNameNames summ n ns =
ppTypeApp n [] ns ppDN ppTyName
where
- ppDN is_infix = ppBinderFixity is_infix summ . nameOccName . getName
- ppBinderFixity True = ppBinderInfix
- ppBinderFixity False = ppBinder
+ ppDN notation = ppBinderFixity notation summ . nameOccName . getName
+ ppBinderFixity Infix = ppBinderInfix
+ ppBinderFixity _ = ppBinder
-- | General printing of type applications
-ppTypeApp :: DocName -> [a] -> [a] -> (Bool -> DocName -> Html) -> (a -> Html) -> Html
+ppTypeApp :: DocName -> [a] -> [a] -> (Notation -> DocName -> Html) -> (a -> Html) -> Html
ppTypeApp n [] (t1:t2:rest) ppDN ppT
| operator, not . null $ rest = parens opApp <+> hsep (map ppT rest)
| operator = opApp
where
operator = isNameSym . getName $ n
- opApp = ppT t1 <+> ppDN True n <+> ppT t2
+ opApp = ppT t1 <+> ppDN Infix n <+> ppT t2
-ppTypeApp n ks ts ppDN ppT = ppDN False n <+> hsep (map ppT $ ks ++ ts)
+ppTypeApp n ks ts ppDN ppT = ppDN Prefix n <+> hsep (map ppT $ ks ++ ts)
-------------------------------------------------------------------------------
@@ -350,7 +350,7 @@ ppFds fds unicode qual =
char '|' <+> hsep (punctuate comma (map (fundep . unLoc) fds))
where
fundep (vars1,vars2) = ppVars vars1 <+> arrow unicode <+> ppVars vars2
- ppVars = hsep . map (ppDocName qual (Just False))
+ ppVars = hsep . map (ppDocName qual Prefix)
ppShortClassDecl :: Bool -> LinksInfo -> TyClDecl DocName -> SrcSpan
-> [(DocName, DocForDecl DocName)] -> Bool -> Qualification
@@ -564,7 +564,7 @@ ppConstrHdr forall_ tvs ctxt unicode qual
<+> darrow unicode +++ toHtml " ")
where
ppForall = case forall_ of
- Explicit -> forallSymbol unicode <+> hsep (map (ppName (Just False)) tvs) <+> toHtml ". "
+ Explicit -> forallSymbol unicode <+> hsep (map (ppName Prefix) tvs) <+> toHtml ". "
Implicit -> noHtml
@@ -728,7 +728,7 @@ ppr_mono_ty ctxt_prec (HsForAllTy expl tvs ctxt ty) unicode qual
hsep [ppForAll expl tvs ctxt unicode qual, ppr_mono_lty pREC_TOP ty unicode qual]
ppr_mono_ty _ (HsBangTy b ty) u q = ppBang b +++ ppLParendType u q ty
-ppr_mono_ty _ (HsTyVar name) _ q = ppDocName q (Just False) name
+ppr_mono_ty _ (HsTyVar name) _ q = ppDocName q Prefix name
ppr_mono_ty ctxt_prec (HsFunTy ty1 ty2) u q = ppr_fun_ty ctxt_prec ty1 ty2 u q
ppr_mono_ty _ (HsTupleTy con tys) u q = tupleParens con (map (ppLType u q) tys)
ppr_mono_ty _ (HsKindSig ty kind) u q =
@@ -756,7 +756,7 @@ ppr_mono_ty ctxt_prec (HsOpTy ty1 (_, op) ty2) unicode qual
= maybeParen ctxt_prec pREC_FUN $
ppr_mono_lty pREC_OP ty1 unicode qual <+> ppr_op <+> ppr_mono_lty pREC_OP ty2 unicode qual
where
- ppr_op = ppLDocName qual (Just True) op
+ ppr_op = ppLDocName qual Infix op
ppr_mono_ty ctxt_prec (HsParTy ty) unicode qual
-- = parens (ppr_mono_lty pREC_TOP ty)