File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
lib/Language/Haskell/Stylish
tests/Language/Haskell/Stylish/Step/Data Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ import Prelude hiding (lines)
5757
5858--------------------------------------------------------------------------------
5959import ApiAnnotation (AnnKeywordId (.. ), AnnotationComment (.. ))
60+ import BasicTypes (PromotionFlag (.. ))
6061import GHC.Hs.Extension (GhcPs , NoExtField (.. ))
6162import GHC.Hs.Types (HsType (.. ))
6263import 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
Original file line number Diff line number Diff 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
7576case00 :: 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+
12771294sameSameStyle :: Config
12781295sameSameStyle = Config SameLine SameLine 2 2 False True SameLine False True NoMaxColumns
12791296
You can’t perform that action at this time.
0 commit comments