on master help sign in
Hang record constructor fields
commit58f81876e9d48dc9b0127fd792a54e324a642627 authorUtku Demir <me@utdemir.com> dateThu 15 Aug 2019, 19:29 (7 years ago) parent625f239
3 files changed+38−2
data/examples/declaration/value/function/record-constructors-out.hs+19 data/examples/declaration/value/function/record-constructors.hs+16 src/Ormolu/Printer/Meat/Declaration/Value.hs+3−2
data/examples/declaration/value/function/record-constructors-out.hs+19
@@ -6,3 +6,22 @@ bar = Bar
66 }
77
88baz = Baz {}
9+
10+aLongVariableName =
11+ ALongRecordName
12+ { short = baz,
13+ aLongRecordFieldName = YetAnotherLongRecordName
14+ { yetAnotherLongRecordFieldName = "a long string"
15+ },
16+ aLongRecordFieldName2 =
17+ Just
18+ YetAnotherLongRecordName
19+ { yetAnotherLongRecordFieldName = "a long string",
20+ yetAnotherLongRecordFieldName =
21+ Just
22+ "a long string"
23+ },
24+ aLongRecordFieldName3 = do
25+ foo
26+ bar
27+ }
data/examples/declaration/value/function/record-constructors.hs+16
@@ -4,3 +4,19 @@ bar = Bar {
44 def = Foo {a = 10}
55}
66baz = Baz{ }
7+
8+aLongVariableName =
9+ ALongRecordName
10+ { short = baz,
11+ aLongRecordFieldName = YetAnotherLongRecordName
12+ { yetAnotherLongRecordFieldName = "a long string"
13+ },
14+ aLongRecordFieldName2 = Just YetAnotherLongRecordName
15+ { yetAnotherLongRecordFieldName = "a long string",
16+ yetAnotherLongRecordFieldName = Just
17+ "a long string"
18+ },
19+ aLongRecordFieldName3 = do
20+ foo
21+ bar
22+ }
src/Ormolu/Printer/Meat/Declaration/Value.hs+3−2
@@ -434,8 +434,9 @@ p_hsRecField
434434p_hsRecField = \HsRecField {..} -> do
435435 located hsRecFieldLbl atom
436436 unless hsRecPun $ do
437− txt " = "
438− located hsRecFieldArg p_hsExpr
437+ txt " ="
438+ let placement = exprPlacement (unLoc hsRecFieldArg)
439+ placeHanging placement $ located hsRecFieldArg p_hsExpr
439440
440441p_hsTupArg :: HsTupArg GhcPs -> R ()
441442p_hsTupArg = \case