Support hanging type signature config option
parent
43abab2dd2
commit
37e355fea5
|
@ -173,6 +173,7 @@ defaultTestConfig = Config
|
|||
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
||||
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
||||
, _lconfig_alignmentBreakOnMultiline = coerce True
|
||||
, _lconfig_hangingTypeSignature = coerce False
|
||||
}
|
||||
, _conf_errorHandling = (_conf_errorHandling staticDefaultConfig)
|
||||
{ _econf_omit_output_valid_check = coerce True
|
||||
|
|
|
@ -55,6 +55,7 @@ defaultTestConfig = Config
|
|||
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
||||
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
||||
, _lconfig_alignmentBreakOnMultiline = coerce True
|
||||
, _lconfig_hangingTypeSignature = coerce False
|
||||
}
|
||||
, _conf_errorHandling = (_conf_errorHandling staticDefaultConfig)
|
||||
{ _econf_ExactPrintFallback = coerce ExactPrintFallbackModeNever
|
||||
|
|
|
@ -63,6 +63,7 @@ staticDefaultConfig = Config
|
|||
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
||||
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
||||
, _lconfig_alignmentBreakOnMultiline = coerce True
|
||||
, _lconfig_hangingTypeSignature = coerce False
|
||||
}
|
||||
, _conf_errorHandling = ErrorHandlingConfig
|
||||
{ _econf_produceOutputOnErrors = coerce False
|
||||
|
@ -156,6 +157,7 @@ configParser = do
|
|||
, _lconfig_columnAlignMode = mempty
|
||||
, _lconfig_alignmentLimit = mempty
|
||||
, _lconfig_alignmentBreakOnMultiline = mempty
|
||||
, _lconfig_hangingTypeSignature = mempty
|
||||
}
|
||||
, _conf_errorHandling = ErrorHandlingConfig
|
||||
{ _econf_produceOutputOnErrors = wrapLast $ falseToNothing outputOnErrors
|
||||
|
|
|
@ -73,6 +73,17 @@ data CLayoutConfig f = LayoutConfig
|
|||
-- short <- some more stuff
|
||||
-- that requires two lines
|
||||
-- loooooooong <- stuff
|
||||
, _lconfig_hangingTypeSignature :: f (Last Bool)
|
||||
-- Do not put "::" in a new line, and use hanging indentation for the
|
||||
-- signature, i.e.:
|
||||
-- func :: SomeLongStuff
|
||||
-- -> SomeLongStuff
|
||||
-- instead of the usual
|
||||
-- func
|
||||
-- :: SomeLongStuff
|
||||
-- -> SomeLongStuff
|
||||
-- As usual for hanging indentation, the result will be
|
||||
-- context-sensitive (in the function name).
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
|
|
|
@ -52,6 +52,22 @@ layoutSig lsig@(L _loc sig) = case sig of
|
|||
let nameStr = Text.intercalate (Text.pack ", ") $ nameStrs
|
||||
typeDoc <- docSharedWrapper layoutType typ
|
||||
hasComments <- hasAnyCommentsBelow lsig
|
||||
shouldBeHanging <- mAsk
|
||||
<&> _conf_layout
|
||||
.> _lconfig_hangingTypeSignature
|
||||
.> confUnpack
|
||||
if shouldBeHanging
|
||||
then docSeq
|
||||
[ appSep $ docWrapNodeRest lsig $ docLit nameStr
|
||||
, docSetBaseY $ docLines
|
||||
[ docCols
|
||||
ColTyOpPrefix
|
||||
[ docLit $ Text.pack ":: "
|
||||
, docAddBaseY (BrIndentSpecial 3) $ typeDoc
|
||||
]
|
||||
]
|
||||
]
|
||||
else
|
||||
docAlt
|
||||
$ [ docSeq
|
||||
[ appSep $ docWrapNodeRest lsig $ docLit nameStr
|
||||
|
|
Loading…
Reference in New Issue