From af938b87f404f62098044d9a4aad72d74f8ae8a2 Mon Sep 17 00:00:00 2001 From: joshvera Date: Thu, 13 Oct 2016 11:57:10 -0400 Subject: [PATCH] Omit a function call's arguments if it's arguments match the underlying anonymous function's arguments --- src/DiffSummary.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index b71e808a4..159aa66bc 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -163,8 +163,16 @@ toTermName source term = case unwrap term of S.Indexed children -> fromMaybe "branch" $ (toCategoryName . category) . extract <$> head children Leaf leaf -> toCategoryName leaf S.Assignment identifier _ -> toTermName' identifier - S.Function identifier _ _ -> toTermName' identifier - S.FunctionCall i args -> toTermName' i <> "(" <> intercalate ", " (toArgName <$> args) <> ")" + S.Function identifier _ _ -> + toTermName' identifier + S.FunctionCall i args -> case unwrap i of + S.AnonymousFunction params _ -> + -- Omit a function call's arguments if it's arguments match the underlying + -- anonymous function's arguments. + if (category . extract <$> args) == (category . extract <$> params) + then toTermName' i + else "(" <> toTermName' i <> ")" <> paramsToArgNames args + _ -> toTermName' i <> paramsToArgNames args S.MemberAccess base property -> case (unwrap base, unwrap property) of (S.FunctionCall{}, S.FunctionCall{}) -> toTermName' base <> "()." <> toTermName' property <> "()" (S.FunctionCall{}, _) -> toTermName' base <> "()." <> toTermName' property