on master help sign in
Hang record constructor fields
58f8187Utku Demir
data/examples/declaration/value/function/record-constructors-out.hs+19
@@ -6,3 +6,22 @@ bar = Bar
6 }
6 }
7
7
8baz = Baz {}
8baz = 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 {
4 def = Foo {a = 10}
4 def = Foo {a = 10}
5}
5}
6baz = Baz{ }
6baz = 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
434p_hsRecField = \HsRecField {..} -> do
434p_hsRecField = \HsRecField {..} -> do
435 located hsRecFieldLbl atom
435 located hsRecFieldLbl atom
436 unless hsRecPun $ do
436 unless hsRecPun $ do
437− txt " = "
437+ txt " ="
438+ let placement = exprPlacement (unLoc hsRecFieldArg)
438− located hsRecFieldArg p_hsExpr
439+ placeHanging placement $ located hsRecFieldArg p_hsExpr
439
440
440p_hsTupArg :: HsTupArg GhcPs -> R ()
441p_hsTupArg :: HsTupArg GhcPs -> R ()
441p_hsTupArg = \case
442p_hsTupArg = \case