on master help sign in
Fix type signature declarations for multiple values

Maybe the style is debatable, but I don't know a better way to format it in multi-line.

commit1e6f4cdc9577efafd5c63980061277b31e601db2 authormrkkrp <mark.karpov@tweag.io> dateWed 12 Jun 2019, 16:07 (7 years ago) parent803f76a
3 files changed+21−3
data/examples/declaration/signature/type/multi-value-out.hs+6 data/examples/declaration/signature/type/multi-value.hs+5 src/Ormolu/Printer/Meat/Declaration/Signature.hs+10−3
data/examples/declaration/signature/type/multi-value-out.hsnew file+6
@@ -0,0 +1,6 @@
1+foo, bar :: Int
2+
3+foo
4+ , bar
5+ , baz
6+ :: Int
data/examples/declaration/signature/type/multi-value.hsnew file+5
@@ -0,0 +1,5 @@
1+foo, bar :: Int
2+
3+foo,
4+ bar,
5+ baz :: Int
src/Ormolu/Printer/Meat/Declaration/Signature.hs+10−3
@@ -35,9 +35,16 @@ p_typeSig
3535 :: [Located RdrName] -- ^ Names (before @::@)
3636 -> LHsSigWcType GhcPs -- ^ Type
3737 -> R ()
38−p_typeSig names hswc = do
39− spaceSep p_rdrName names
40− p_typeAscription hswc
38+p_typeSig [] _ = return () -- should not happen though
39+p_typeSig (n:ns) hswc = do
40+ p_rdrName n
41+ if null ns
42+ then p_typeAscription hswc
43+ else inci $ do
44+ vlayout (return ()) newline
45+ comma
46+ velt (withSep comma p_rdrName ns)
47+ p_typeAscription hswc
4148
4249p_typeAscription
4350 :: LHsSigWcType GhcPs