File tree Expand file tree Collapse file tree 3 files changed +32
-9
lines changed
lib/Language/Haskell/Stylish/Step
tests/Language/Haskell/Stylish/Step/Data Expand file tree Collapse file tree 3 files changed +32
-9
lines changed Original file line number Diff line number Diff line change 29
29
name : Cache ~/.stack
30
30
with :
31
31
path : ~/.stack
32
- key : ${{ runner.os }}-${{ matrix.ghc }}-v7
32
+ key : ${{ runner.os }}-${{ matrix.ghc }}-v8
33
33
34
34
- name : Add ~/.local/bin to PATH
35
35
run : echo "$HOME/.local/bin" >> $GITHUB_PATH
Original file line number Diff line number Diff line change @@ -357,19 +357,15 @@ putConstructor cfg consIndent (L _ cons) = case cons of
357
357
putText " ::"
358
358
space
359
359
360
- when (unLocated con_forall) do
361
- putText " forall"
362
- space
363
- sep space (fmap putOutputable $ hsq_explicit con_qvars)
364
- dot
365
- space
366
-
360
+ putForAll con_forall $ hsq_explicit con_qvars
367
361
forM_ con_mb_cxt (putContext cfg . unLocated)
368
362
putType con_res_ty
369
363
370
364
XConDecl x ->
371
365
noExtCon x
372
- ConDeclH98 {.. } ->
366
+ ConDeclH98 {.. } -> do
367
+ putForAll con_forall con_ex_tvs
368
+ forM_ con_mb_cxt (putContext cfg . unLocated)
373
369
case con_args of
374
370
InfixCon arg1 arg2 -> do
375
371
putType arg1
@@ -467,6 +463,15 @@ putNewtypeConstructor cfg (L _ cons) = case cons of
467
463
, " GADT encountered in newtype"
468
464
]
469
465
466
+ putForAll :: Located Bool -> [Located (HsTyVarBndr GhcPs )] -> P ()
467
+ putForAll forall ex_tvs =
468
+ when (unLocated forall) do
469
+ putText " forall"
470
+ space
471
+ sep space (fmap putOutputable ex_tvs)
472
+ dot
473
+ space
474
+
470
475
putContext :: Config -> HsContext GhcPs -> P ()
471
476
putContext Config {.. } = suffix (space >> putText " =>" >> space) . \ case
472
477
[L _ (HsParTy _ tp)] | cCurriedContext ->
Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ tests = testGroup "Language.Haskell.Stylish.Step.Data.Tests"
71
71
, testCase " case 56" case56
72
72
, testCase " case 57" case57
73
73
, testCase " case 58" case58
74
+ , testCase " case 59" case59
75
+ , testCase " case 60" case60
74
76
]
75
77
76
78
case00 :: Assertion
@@ -1291,6 +1293,22 @@ case58 = expected @=? testStep (step sameIndentStyle) input
1291
1293
1292
1294
expected = input
1293
1295
1296
+ -- | Don't remove existential quantification
1297
+ --
1298
+ -- See https://github.com/haskell/stylish-haskell/issues/339
1299
+ case59 :: Assertion
1300
+ case59 = assertSnippet (step defaultConfig)
1301
+ [ " data Foo = forall (a :: *) . Bar a" ]
1302
+ [ " data Foo = forall (a :: *). Bar a" ]
1303
+
1304
+ -- | Don't remove existential quantification
1305
+ --
1306
+ -- See https://github.com/haskell/stylish-haskell/issues/339
1307
+ case60 :: Assertion
1308
+ case60 = assertSnippet (step defaultConfig)
1309
+ [ " data Foo = forall a . Bar a" ]
1310
+ [ " data Foo = forall a. Bar a" ]
1311
+
1294
1312
sameSameStyle :: Config
1295
1313
sameSameStyle = Config SameLine SameLine 2 2 False True SameLine False True NoMaxColumns
1296
1314
You can’t perform that action at this time.
0 commit comments