1
1
mirror of https://github.com/google/ormolu.git synced 2024-09-11 08:05:24 +03:00

Do not lump together forall and constructors when deciding on layout

This commit is contained in:
Mark Karpov 2020-04-10 14:29:27 +02:00
parent 9b342488be
commit d96f7e3e00
5 changed files with 30 additions and 10 deletions

View File

@ -20,8 +20,9 @@
expressions. [Issue 513](https://github.com/tweag/ormolu/issues/513).
* Made rendering of data type definitions, value-level applications, and
application of types use the same style. [Issue
427](https://github.com/tweag/ormolu/issues/427).
application of types use the same style. Moreover, existential now doesn't
cause the data constructor be unconditionally rendered in multiline layout
[Issue 427](https://github.com/tweag/ormolu/issues/427).
* Implemented support for the new language extension `ImportQualifiedPost`.

View File

@ -3,3 +3,15 @@
data Foo
= forall a. MkFoo a (a -> Bool)
| forall a. Eq a => MkBar a
data Bar
= forall x y.
Bar x y x y
data Baz
= forall x y.
Baz
x
y
x
y

View File

@ -3,3 +3,10 @@
data Foo
= forall a. MkFoo a (a -> Bool)
| forall a. Eq a => MkBar a
data Bar = forall x y.
Bar x y x y
data Baz = forall x y.
Baz x y x
y

View File

@ -12,8 +12,7 @@ data D
)
(x :: *)
(y :: *).
D
(f x y)
D (f x y)
data G where
G ::

View File

@ -124,18 +124,19 @@ p_conDecl = \case
p_hsType (unLoc con_res_ty)
ConDeclH98 {..} -> do
mapM_ (p_hsDocString Pipe True) con_doc
let conDeclSpn =
[getLoc con_name]
<> [getLoc con_forall]
let conDeclWithContextSpn =
[getLoc con_forall]
<> fmap getLoc con_ex_tvs
<> maybeToList (fmap getLoc con_mb_cxt)
<> conArgsSpans con_args
switchLayout conDeclSpn $ do
<> conDeclSpn
conDeclSpn =
getLoc con_name : conArgsSpans con_args
switchLayout conDeclWithContextSpn $ do
when (unLoc con_forall) $ do
p_forallBndrs ForallInvis p_hsTyVarBndr con_ex_tvs
breakpoint
forM_ con_mb_cxt p_lhsContext
case con_args of
switchLayout conDeclSpn $ case con_args of
PrefixCon xs -> do
p_rdrName con_name
unless (null xs) breakpoint