Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/Language/Haskell/Stylish/Step/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import GHC.Hs.Types (ConDeclField (..),
HsConDetails (..), HsContext,
HsImplicitBndrs (..),
HsTyVarBndr (..),
HsType (..), LHsQTyVars (..))
HsType (..), LHsQTyVars (..), LHsKind)
import RdrName (RdrName)
import SrcLoc (GenLocated (..), Located,
RealLocated)
Expand Down Expand Up @@ -312,9 +312,11 @@ putName decl@MkDataDecl{..} =
putRdrName dataDeclName
space
forM_ secondTvar putOutputable
maybePutKindSig
else do
putRdrName dataDeclName
forM_ (hsq_explicit dataTypeVars) (\t -> space >> putOutputable t)
maybePutKindSig

where
firstTvar :: Maybe (Located (HsTyVarBndr GhcPs))
Expand All @@ -330,6 +332,12 @@ putName decl@MkDataDecl{..} =
& drop 1
& listToMaybe

maybePutKindSig :: Printer ()
maybePutKindSig = forM_ maybeKindSig (\k -> space >> putText "::" >> space >> putOutputable k)

maybeKindSig :: Maybe (LHsKind GhcPs)
maybeKindSig = dd_kindSig dataDefn

putConstructor :: Config -> Int -> Located (ConDecl GhcPs) -> P ()
putConstructor cfg consIndent (L _ cons) = case cons of
ConDeclGADT{..} -> do
Expand Down
12 changes: 12 additions & 0 deletions tests/Language/Haskell/Stylish/Step/Data/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ tests = testGroup "Language.Haskell.Stylish.Step.Data.Tests"
, testCase "case 60" case60
, testCase "case 61 (issue 282)" case61
, testCase "case 62 (issue 273)" case62
, testCase "case 63 (issue 338)" case63
]

case00 :: Assertion
Expand Down Expand Up @@ -1377,6 +1378,17 @@ case62 = expected @=? testStep (step sameIndentStyle) input
, " }"
]

case63 :: Assertion
case63 = expected @=? testStep (step indentIndentStyle) input
where
input = unlines
[ "module Herp where"
, ""
, "data Foo :: * -> * where"
, " Bar :: () -> Foo ()"
]
expected = input

sameSameStyle :: Config
sameSameStyle = Config SameLine SameLine 2 2 False True SameLine False True NoMaxColumns

Expand Down