Skip to content

Commit a0c4256

Browse files
authored
Don't remove ticks on promoted data types
1 parent 84770e3 commit a0c4256

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/Language/Haskell/Stylish/Printer.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import Prelude hiding (lines)
5757

5858
--------------------------------------------------------------------------------
5959
import ApiAnnotation (AnnKeywordId(..), AnnotationComment(..))
60+
import BasicTypes (PromotionFlag(..))
6061
import GHC.Hs.Extension (GhcPs, NoExtField(..))
6162
import GHC.Hs.Types (HsType(..))
6263
import Module (ModuleName, moduleNameString)
@@ -229,7 +230,10 @@ putType ltp = case unLocated ltp of
229230
putRdrName op
230231
space
231232
putType rhs
232-
HsTyVar NoExtField _ rdrName ->
233+
HsTyVar NoExtField flag rdrName -> do
234+
case flag of
235+
IsPromoted -> putText "'"
236+
NotPromoted -> pure ()
233237
putRdrName rdrName
234238
HsTyLit _ tp ->
235239
putOutputable tp

tests/Language/Haskell/Stylish/Step/Data/Tests.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ tests = testGroup "Language.Haskell.Stylish.Step.Data.Tests"
7070
, testCase "case 55" case55
7171
, testCase "case 56" case56
7272
, testCase "case 57" case57
73+
, testCase "case 58" case58
7374
]
7475

7576
case00 :: Assertion
@@ -1274,6 +1275,22 @@ case57 = assertSnippet (step defaultConfig)
12741275
, " }"
12751276
]
12761277

1278+
-- | Should not break DataKinds in records
1279+
--
1280+
-- See https://github.com/jaspervdj/stylish-haskell/issues/330
1281+
case58 :: Assertion
1282+
case58 = expected @=? testStep (step sameIndentStyle) input
1283+
where
1284+
input = unlines
1285+
[ "module Herp where"
1286+
, ""
1287+
, "data Foo a = Foo"
1288+
, " { foo :: Foo 'True"
1289+
, " }"
1290+
]
1291+
1292+
expected = input
1293+
12771294
sameSameStyle :: Config
12781295
sameSameStyle = Config SameLine SameLine 2 2 False True SameLine False True NoMaxColumns
12791296

0 commit comments

Comments
 (0)