Skip to content

Commit d214e2e

Browse files
committed
Fix some issues with the pretty printer, fix purescript#2039
1 parent 820e96f commit d214e2e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Language/PureScript/Pretty/Values.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ prettyPrintValue d (IfThenElse cond th el) =
5454
// moveRight 2 (vcat left [ text "then " <> prettyPrintValueAtom (d - 1) th
5555
, text "else " <> prettyPrintValueAtom (d - 1) el
5656
])
57-
prettyPrintValue d (Accessor prop val) = prettyPrintValueAtom (d - 1) val <> textT ("." Monoid.<> prettyPrintObjectKey prop)
58-
prettyPrintValue d (ObjectUpdate o ps) = prettyPrintValueAtom (d - 1) o <> text " " <> list '{' '}' (\(key, val) -> textT (key Monoid.<> " = ") <> prettyPrintValue (d - 1) val) ps
57+
prettyPrintValue d (Accessor prop val) = prettyPrintValueAtom (d - 1) val `before` textT ("." Monoid.<> prettyPrintObjectKey prop)
58+
prettyPrintValue d (ObjectUpdate o ps) = prettyPrintValueAtom (d - 1) o `beforeWithSpace` list '{' '}' (\(key, val) -> textT (key Monoid.<> " = ") <> prettyPrintValue (d - 1) val) ps
5959
prettyPrintValue d (App val arg) = prettyPrintValueAtom (d - 1) val `beforeWithSpace` prettyPrintValueAtom (d - 1) arg
6060
prettyPrintValue d (Abs (Left arg) val) = text ('\\' : T.unpack (showIdent arg) ++ " -> ") // moveRight 2 (prettyPrintValue (d - 1) val)
6161
prettyPrintValue d (Abs (Right arg) val) = text ('\\' : T.unpack (prettyPrintBinder arg) ++ " -> ") // moveRight 2 (prettyPrintValue (d - 1) val)
6262
prettyPrintValue d (TypeClassDictionaryConstructorApp className ps) =
6363
text (T.unpack (runProperName (disqualify className)) ++ " ") <> prettyPrintValueAtom (d - 1) ps
6464
prettyPrintValue d (Case values binders) =
65-
(text "case " <> foldl1 beforeWithSpace (map (prettyPrintValueAtom (d - 1)) values) <> text " of") //
65+
(text "case " <> foldr beforeWithSpace (text "of") (map (prettyPrintValueAtom (d - 1)) values)) //
6666
moveRight 2 (vcat left (map (prettyPrintCaseAlternative (d - 1)) binders))
6767
prettyPrintValue d (Let ds val) =
6868
text "let" //
@@ -96,7 +96,7 @@ prettyPrintValueAtom d (BinaryNoParens op lhs rhs) =
9696
prettyPrintValue (d - 1) lhs `beforeWithSpace` printOp op `beforeWithSpace` prettyPrintValue (d - 1) rhs
9797
where
9898
printOp (Op (Qualified _ name)) = text $ T.unpack $ runOpName name
99-
printOp expr = text "`" <> prettyPrintValue (d - 1) expr <> text "`"
99+
printOp expr = text "`" <> prettyPrintValue (d - 1) expr `before` text "`"
100100
prettyPrintValueAtom d (TypedValue _ val _) = prettyPrintValueAtom d val
101101
prettyPrintValueAtom d (PositionedValue _ _ val) = prettyPrintValueAtom d val
102102
prettyPrintValueAtom d (Parens expr) = (text "(" <> prettyPrintValue d expr) `before` text ")"

0 commit comments

Comments
 (0)