on master help sign in
Prettier printing for infix functions like `div`
commitabb6dc19f62775a511e703f3b4be25c0cf4b497c authorEvan Czaplicki <info@elm-lang.org> dateThu 25 Jul 2013, 15:55 (13 years ago) parentb6144ae
1 file changed+3−2
compiler/SourceSyntax/Expression.hs+3−2
compiler/SourceSyntax/Expression.hs+3−2
@@ -55,11 +55,12 @@ instance Pretty (Expr t v) where
5555 Var x -> variable x
5656 Range e1 e2 -> P.brackets (pretty e1 <> P.text ".." <> pretty e2)
5757 ExplicitList es -> P.brackets (commaCat (map pretty es))
58− Binop op e1 e2 -> P.sep [ prettyParens e1 <+> P.text op, prettyParens e2 ]
58+ Binop op e1 e2 -> P.sep [ prettyParens e1 <+> P.text op', prettyParens e2 ]
59+ where op' = if Help.isOp op then op else "`" ++ op ++ "`"
5960 Lambda p e -> let (ps,body) = collectLambdas (Location.none $ Lambda p e)
6061 in P.text "\\" <> P.sep ps <+> P.text "->" <+> pretty body
6162 App _ _ -> P.hang func 2 (P.sep args)
62− where func:args = map prettyParens (collectApps (Location.none expr))
63+ where func:args = map prettyParens (collectApps (Location.none expr))
6364 MultiIf branches -> P.text "if" $$ nest 3 (vcat $ map iff branches)
6465 where
6566 iff (b,e) = P.text "|" <+> P.hang (pretty b <+> P.text "->") 2 (pretty e)