diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2016-12-08 10:43:32 +0200 |
---|---|---|
committer | Alan Zimmerman <alan.zimm@gmail.com> | 2016-12-12 20:50:56 +0200 |
commit | 8f6d241a74efa6f6280689a9b14c36c6a9f4c231 (patch) | |
tree | 166fabd22a3f726364eb5f7492bcf5d2ec59c0f4 /compiler/utils | |
parent | bc3d37dada357b04fc5a35f740b4fe7e05292b06 (diff) | |
download | haskell-8f6d241a74efa6f6280689a9b14c36c6a9f4c231.tar.gz |
Add infix flag for class and data declarations
Summary:
At the moment, data and type declarations using infix formatting produce the
same AST as those using prefix.
So
type a ++ b = c
and
type (++) a b = c
cannot be distinguished in the parsed source, without looking at the OccName
details of the constructor being defined.
Having access to the OccName requires an additional constraint which explodes
out over the entire AST because of its recursive definitions.
In keeping with moving the parsed source to more directly reflect the source
code as parsed, add a specific flag to the declaration to indicate the fixity,
as used in a Match now too.
Note: this flag is to capture the fixity used for the lexical definition of the
type, primarily for use by ppr and ghc-exactprint.
Updates haddock submodule.
Test Plan: ./validate
Reviewers: mpickering, goldfire, bgamari, austin
Reviewed By: mpickering
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2828
GHC Trac Issues: #12942
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/BooleanFormula.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/utils/BooleanFormula.hs b/compiler/utils/BooleanFormula.hs index ec9a8892c6..13f6e21f31 100644 --- a/compiler/utils/BooleanFormula.hs +++ b/compiler/utils/BooleanFormula.hs @@ -23,7 +23,6 @@ import MonadUtils import Outputable import Binary import SrcLoc -import OccName ( HasOccName(..), isSymOcc ) ---------------------------------------------------------------------- -- Boolean formula type and smart constructors @@ -201,14 +200,14 @@ pprBooleanFormulaNice = pprBooleanFormula' pprVar pprAnd pprOr 0 pprAnd' xs@(_:_) = fsep (punctuate comma (init xs)) <> text ", and" <+> last xs pprOr p xs = cparen (p > 1) $ text "either" <+> sep (intersperse (text "or") xs) -instance (Outputable a, HasOccName a) => Outputable (BooleanFormula a) where +instance (OutputableBndr a) => Outputable (BooleanFormula a) where ppr = pprBooleanFormulaNormal -pprBooleanFormulaNormal :: (Outputable a, HasOccName a) +pprBooleanFormulaNormal :: (OutputableBndr a) => BooleanFormula a -> SDoc pprBooleanFormulaNormal = go where - go (Var x) = pprPrefixVar (isSymOcc (occName x)) (ppr x) + go (Var x) = pprPrefixOcc x go (And xs) = fsep $ punctuate comma (map (go . unLoc) xs) go (Or []) = keyword $ text "FALSE" go (Or xs) = fsep $ intersperse vbar (map (go . unLoc) xs) |