From 9e6a8bf80cc3ad0fa4e1e2ec4d4efa833a831857 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Wed, 11 Sep 2019 00:10:33 +0200 Subject: [PATCH] let-formatting: Insert hardline in front of the '=' instead of behind Fixes #1301. --- dhall/src/Dhall/Pretty/Internal.hs | 2 +- dhall/tests/format/issue1301A.dhall | 5 +++++ dhall/tests/format/issue1301B.dhall | 5 +++++ dhall/tests/format/letLongCommentsB.dhall | 4 ++-- dhall/tests/format/letNewlineCommentsB.dhall | 4 ++-- 5 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 dhall/tests/format/issue1301A.dhall create mode 100644 dhall/tests/format/issue1301B.dhall diff --git a/dhall/src/Dhall/Pretty/Internal.hs b/dhall/src/Dhall/Pretty/Internal.hs index 683d8f7e7..bd308913b 100644 --- a/dhall/src/Dhall/Pretty/Internal.hs +++ b/dhall/src/Dhall/Pretty/Internal.hs @@ -541,7 +541,7 @@ prettyCharacterSet characterSet expression = <> Pretty.align ( renderSrc src0 mempty <> prettyLabel c <> renderSrc src1 Pretty.hardline - <> colon <> renderSrc src3 space <> prettyExpression d <> space <> equals <> renderSrc src2 Pretty.hardline + <> colon <> renderSrc src3 space <> prettyExpression d <> Pretty.hardline <> equals <> renderSrc src2 space <> prettyExpression e ) diff --git a/dhall/tests/format/issue1301A.dhall b/dhall/tests/format/issue1301A.dhall new file mode 100644 index 000000000..85bbbedc1 --- /dev/null +++ b/dhall/tests/format/issue1301A.dhall @@ -0,0 +1,5 @@ +let attribute + : Text → Text → { mapKey : Text, mapValue : Text } + = λ(key : Text) → λ(value : Text) → { mapKey = key, mapValue = value } + +in attribute diff --git a/dhall/tests/format/issue1301B.dhall b/dhall/tests/format/issue1301B.dhall new file mode 100644 index 000000000..254ada840 --- /dev/null +++ b/dhall/tests/format/issue1301B.dhall @@ -0,0 +1,5 @@ +let attribute + : Text → Text → { mapKey : Text, mapValue : Text } + = λ(key : Text) → λ(value : Text) → { mapKey = key, mapValue = value } + +in attribute \ No newline at end of file diff --git a/dhall/tests/format/letLongCommentsB.dhall b/dhall/tests/format/letLongCommentsB.dhall index 117a87e0d..1eac41d18 100644 --- a/dhall/tests/format/letLongCommentsB.dhall +++ b/dhall/tests/format/letLongCommentsB.dhall @@ -1,5 +1,5 @@ let x - {- foo -} : {- bar -} Bool = - {- bla -} True + {- foo -} : {- bar -} Bool + = {- bla -} True in x \ No newline at end of file diff --git a/dhall/tests/format/letNewlineCommentsB.dhall b/dhall/tests/format/letNewlineCommentsB.dhall index 1cb637ae1..e37175e78 100644 --- a/dhall/tests/format/letNewlineCommentsB.dhall +++ b/dhall/tests/format/letNewlineCommentsB.dhall @@ -3,7 +3,7 @@ let x = 1 in let {- aaaaaaaaaaaaaaaaaaa -} y : {- bbbbbbbbbbbbbbbbbbbbb - -} Natural = - {- ddddddddddddddddd -} 2 + -} Natural + = {- ddddddddddddddddd -} 2 in x \ No newline at end of file