Commit a035c70f authored by simonmar's avatar simonmar

[project @ 2001-08-16 10:25:21 by simonmar]

Prettier output for GHCi's :info

  - put parenthesis around operators in type signatures
    (both IfaceSig and ClassOpSig)

  - don't use the cryptic '= ::' notation for indicating that a
    class op has a default method, instead put the information in a
    comment after the type.
parent ef32ff0a
......@@ -15,6 +15,7 @@ import {-# SOURCE #-} HsExpr ( HsExpr, pprExpr,
GRHSs, pprPatBind )
-- friends:
import HsImpExp ( ppr_var )
import HsTypes ( HsType )
import CoreSyn ( CoreExpr )
import PprCore ( {- instance Outputable (Expr a) -} )
......@@ -335,12 +336,21 @@ ppr_sig (Sig var ty _)
= sep [ppr var <+> dcolon, nest 4 (ppr ty)]
ppr_sig (ClassOpSig var dm ty _)
= sep [ppr var <+> pp_dm <+> dcolon, nest 4 (ppr ty)]
= getPprStyle $ \ sty ->
if ifaceStyle sty
then sep [ ppr var <+> pp_dm <+> dcolon, nest 4 (ppr ty) ]
else sep [ ppr_var var <+> dcolon,
nest 4 (ppr ty),
nest 4 (pp_dm_comment) ]
where
pp_dm = case dm of
DefMeth _ -> equals -- Default method indicator
GenDefMeth -> semi -- Generic method indicator
NoDefMeth -> empty -- No Method at all
pp_dm_comment = case dm of
DefMeth _ -> text "{- has default method -}"
GenDefMeth -> text "{- has generic method -}"
NoDefMeth -> empty -- No Method at all
ppr_sig (SpecSig var ty _)
= sep [ hsep [text "{-# SPECIALIZE", ppr var, dcolon],
......
......@@ -26,6 +26,7 @@ module HsDecls (
-- friends:
import HsBinds ( HsBinds, MonoBinds, Sig(..), FixitySig(..) )
import HsExpr ( HsExpr )
import HsImpExp ( ppr_var )
import HsTypes
import PprCore ( pprCoreRule )
import HsCore ( UfExpr, UfBinder, HsIdInfo, pprHsIdInfo,
......@@ -456,7 +457,10 @@ instance (NamedThing name, Outputable name, Outputable pat)
=> Outputable (TyClDecl name pat) where
ppr (IfaceSig {tcdName = var, tcdType = ty, tcdIdInfo = info})
= hsep [ppr var, dcolon, ppr ty, pprHsIdInfo info]
= getPprStyle $ \ sty ->
hsep [ if ifaceStyle sty then ppr var else ppr_var var,
dcolon, ppr ty, pprHsIdInfo info
]
ppr (ForeignType {tcdName = tycon})
= hsep [ptext SLIT("foreign import type dotnet"), ppr tycon]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment