on master help sign in
reprime when printing types
7c19935Evan Czaplicki
compiler/Type/PrettyPrint.hs+4−1
@@ -2,6 +2,7 @@
2module Type.PrettyPrint where
2module Type.PrettyPrint where
3
3
4import Text.PrettyPrint
4import Text.PrettyPrint
5+import qualified SourceSyntax.PrettyPrint as Src
5
6
6data ParensWhen = Fn | App | Never
7data ParensWhen = Fn | App | Never
7
8
@@ -10,4 +11,6 @@ class PrettyType a where
10
11
11commaSep docs = sep (punctuate comma docs)
12commaSep docs = sep (punctuate comma docs)
12
13
13−parensIf bool doc = if bool then parens doc else doc
14+parensIf bool doc = if bool then parens doc else doc
15+
16+reprime = Src.reprime
compiler/Type/Type.hs+2−2
@@ -176,7 +176,7 @@ instance PrettyType a => PrettyType (Term1 a) where
176 prettyExt = prty ext
176 prettyExt = prty ext
177 extend | P.render prettyExt == "{}" = P.empty
177 extend | P.render prettyExt == "{}" = P.empty
178 | otherwise = prettyExt <+> P.text "|"
178 | otherwise = prettyExt <+> P.text "|"
179− mkPretty f t = P.text f <+> P.text ":" <+> prty t
179+ mkPretty f t = P.text (reprime f) <+> P.text ":" <+> prty t
180 prettyFields = concatMap (\(f,ts) -> map (mkPretty f) ts) (Map.toList fields)
180 prettyFields = concatMap (\(f,ts) -> map (mkPretty f) ts) (Map.toList fields)
181
181
182
182
@@ -191,7 +191,7 @@ instance PrettyType Descriptor where
191 pretty when desc =
191 pretty when desc =
192 case (structure desc, name desc) of
192 case (structure desc, name desc) of
193 (Just term, _) -> pretty when term
193 (Just term, _) -> pretty when term
194− (_, Just name) -> if not (isTuple name) then P.text name else
194+ (_, Just name) -> if not (isTuple name) then P.text (reprime name) else
195 P.parens . P.text $ replicate (read (drop 6 name) - 1) ','
195 P.parens . P.text $ replicate (read (drop 6 name) - 1) ','
196 _ -> P.text "?"
196 _ -> P.text "?"
197
197