diff options
author | David Waern <david.waern@gmail.com> | 2008-07-24 16:06:18 +0000 |
---|---|---|
committer | David Waern <david.waern@gmail.com> | 2008-07-24 16:06:18 +0000 |
commit | 87453c56ae000c05bb89824e5cce614996a7dfe1 (patch) | |
tree | e5e8b8e2b3fb487133a5f9dd2146c22f4aca55f1 /src/Haddock | |
parent | 0debe1ef5929401a52df3c37ffd09a57bd1c8b8a (diff) |
Drop unnecessary parenthesis in types, put in by the user
We were putting in parenthesis were the user did. Let's remove this since
it just clutters up the types. The types are readable anyway since we print
parens around infix operators and do not rely on fixity levels.
When doing this I discovered that we were relying on user parenthesis when
printin types like (a `O` b) c. This patchs fixes this problem so that
parenthesis are always inserted around an infix op application in case it
is applied to further arguments, or if it's an arguments to a type constructor.
Tests are updated.
Diffstat (limited to 'src/Haddock')
-rw-r--r-- | src/Haddock/Backends/Html.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Haddock/Backends/Html.hs b/src/Haddock/Backends/Html.hs index df03acae..81cae215 100644 --- a/src/Haddock/Backends/Html.hs +++ b/src/Haddock/Backends/Html.hs @@ -1336,10 +1336,13 @@ ppType t = case t of HsSpliceTy _ -> error "ppType" HsDocTy t _ -> ppLType t -} + + -------------------------------------------------------------------------------- -- Rendering of HsType -------------------------------------------------------------------------------- + pREC_TOP = (0 :: Int) -- type in ParseIface.y in GHC pREC_FUN = (1 :: Int) -- btype in ParseIface.y in GHC -- Used for LH arg of (->) @@ -1366,16 +1369,12 @@ ppLType = ppType . unLoc ppLParendType = ppParendType . unLoc -ppType ty = ppr_mono_ty pREC_TOP (prepare ty) +ppType ty = ppr_mono_ty pREC_TOP ty ppParendType ty = ppr_mono_ty pREC_CON ty --- Before printing a type --- (a) Remove outermost HsParTy parens --- (b) Drop top-level for-all type variables in user style --- since they are implicit in Haskell -prepare (HsParTy ty) = prepare (unLoc ty) -prepare ty = ty +-- Drop top-level for-all type variables in user style +-- since they are implicit in Haskell ppForAll exp tvs cxt | show_forall = forall_part <+> ppLContext cxt @@ -1408,14 +1407,15 @@ ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty) hsep [ppr_mono_lty pREC_FUN fun_ty, ppr_mono_lty pREC_CON arg_ty] ppr_mono_ty ctxt_prec (HsOpTy ty1 op ty2) - = maybeParen ctxt_prec pREC_OP $ + = maybeParen ctxt_prec pREC_FUN $ ppr_mono_lty pREC_OP ty1 <+> ppr_op <+> ppr_mono_lty pREC_OP ty2 where ppr_op = if not (isSymOcc occName) then quote (ppLDocName op) else ppLDocName op occName = docNameOcc . unLoc $ op ppr_mono_ty ctxt_prec (HsParTy ty) - = parens (ppr_mono_lty pREC_TOP ty) +-- = parens (ppr_mono_lty pREC_TOP ty) + = ppr_mono_lty ctxt_prec ty ppr_mono_ty ctxt_prec (HsDocTy ty doc) = ppr_mono_lty ctxt_prec ty |