Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
0174be83
Commit
0174be83
authored
24 years ago
by
Simon Peyton Jones
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 2000-07-17 11:28:00 by simonpj]
Print operator names in HsExpr better
parent
397858e2
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/compiler/hsSyn/HsExpr.lhs
+17
-9
17 additions, 9 deletions
ghc/compiler/hsSyn/HsExpr.lhs
with
17 additions
and
9 deletions
ghc/compiler/hsSyn/HsExpr.lhs
+
17
−
9
View file @
0174be83
...
...
@@ -17,7 +17,7 @@ import BasicTypes ( Fixity(..), FixityDirection(..) )
import HsTypes ( HsType )
-- others:
import Name ( Name, isLex
Id
)
import Name ( Name, isLex
Sym
)
import Outputable
import PprType ( pprType, pprParendType )
import Type ( Type )
...
...
@@ -211,7 +211,11 @@ pprExpr :: (Outputable id, Outputable pat)
pprExpr e = pprDeeper (ppr_expr e)
pprBinds b = pprDeeper (ppr b)
ppr_expr (HsVar v) = ppr v
ppr_expr (HsVar v)
-- Put it in parens if it's an operator
| isOperator v = parens (ppr v)
| otherwise = ppr v
ppr_expr (HsIPVar v) = {- char '?' <> -} ppr v
ppr_expr (HsLit lit) = ppr lit
...
...
@@ -241,13 +245,9 @@ ppr_expr (OpApp e1 op fixity e2)
pp_infixly v
= sep [pp_e1, hsep [pp_v_op, pp_e2]]
where
pp_v = ppr v
pp_v_op | isLexId (_PK_ (showSDoc pp_v)) = char '`' <> pp_v <> char '`'
| otherwise = pp_v
-- Put it in backquotes if it's not an operator already
-- We use (showSDoc pp_v), rather than isSymOcc (getOccName v) simply so
-- that we don't need NamedThing in the context of all these funcions.
-- Gruesome, but simple.
pp_v_op | isOperator v = ppr v
| otherwise = char '`' <> ppr v <> char '`'
-- Put it in backquotes if it's not an operator already
ppr_expr (NegApp e _)
= char '-' <+> pprParendExpr e
...
...
@@ -390,6 +390,14 @@ pprParendExpr expr
_ -> parens pp_as_was
\end{code}
\begin{code}
isOperator :: Outputable a => a -> Bool
isOperator v = isLexSym (_PK_ (showSDoc (ppr v)))
-- We use (showSDoc (ppr v)), rather than isSymOcc (getOccName v) simply so
-- that we don't need NamedThing in the context of all these functions.
-- Gruesome, but simple.
\end{code}
%************************************************************************
%* *
\subsection{Record binds}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment