diff options
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/Binary.hs | 15 | ||||
-rw-r--r-- | compiler/utils/BooleanFormula.hs | 16 | ||||
-rw-r--r-- | compiler/utils/Outputable.hs | 4 |
3 files changed, 32 insertions, 3 deletions
diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index 26a4d19366..07eb3bcda8 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -980,3 +980,18 @@ instance Binary Serialized where the_type <- get bh bytes <- get bh return (Serialized the_type bytes) + +instance Binary SourceText where + put_ bh NoSourceText = putByte bh 0 + put_ bh (SourceText s) = do + putByte bh 1 + put_ bh s + + get bh = do + h <- getByte bh + case h of + 0 -> return NoSourceText + 1 -> do + s <- get bh + return (SourceText s) + _ -> panic $ "Binary SourceText:" ++ show h diff --git a/compiler/utils/BooleanFormula.hs b/compiler/utils/BooleanFormula.hs index 4764b1bfce..ec9a8892c6 100644 --- a/compiler/utils/BooleanFormula.hs +++ b/compiler/utils/BooleanFormula.hs @@ -23,6 +23,7 @@ import MonadUtils import Outputable import Binary import SrcLoc +import OccName ( HasOccName(..), isSymOcc ) ---------------------------------------------------------------------- -- Boolean formula type and smart constructors @@ -200,8 +201,19 @@ 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 => Outputable (BooleanFormula a) where - pprPrec = pprBooleanFormula pprPrec +instance (Outputable a, HasOccName a) => Outputable (BooleanFormula a) where + ppr = pprBooleanFormulaNormal + +pprBooleanFormulaNormal :: (Outputable a, HasOccName a) + => BooleanFormula a -> SDoc +pprBooleanFormulaNormal = go + where + go (Var x) = pprPrefixVar (isSymOcc (occName x)) (ppr 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) + go (Parens x) = parens (go $ unLoc x) + ---------------------------------------------------------------------- -- Binary diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs index 1231ab03e5..16f257e017 100644 --- a/compiler/utils/Outputable.hs +++ b/compiler/utils/Outputable.hs @@ -53,7 +53,9 @@ module Outputable ( pprInfixVar, pprPrefixVar, pprHsChar, pprHsString, pprHsBytes, - primFloatSuffix, primDoubleSuffix, + primFloatSuffix, primCharSuffix, primWordSuffix, primDoubleSuffix, + primInt64Suffix, primWord64Suffix, primIntSuffix, + pprPrimChar, pprPrimInt, pprPrimWord, pprPrimInt64, pprPrimWord64, pprFastFilePath, |