Support hanging type signature config option
parent
43abab2dd2
commit
37e355fea5
|
@ -173,6 +173,7 @@ defaultTestConfig = Config
|
||||||
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
||||||
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
||||||
, _lconfig_alignmentBreakOnMultiline = coerce True
|
, _lconfig_alignmentBreakOnMultiline = coerce True
|
||||||
|
, _lconfig_hangingTypeSignature = coerce False
|
||||||
}
|
}
|
||||||
, _conf_errorHandling = (_conf_errorHandling staticDefaultConfig)
|
, _conf_errorHandling = (_conf_errorHandling staticDefaultConfig)
|
||||||
{ _econf_omit_output_valid_check = coerce True
|
{ _econf_omit_output_valid_check = coerce True
|
||||||
|
|
|
@ -55,6 +55,7 @@ defaultTestConfig = Config
|
||||||
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
||||||
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
||||||
, _lconfig_alignmentBreakOnMultiline = coerce True
|
, _lconfig_alignmentBreakOnMultiline = coerce True
|
||||||
|
, _lconfig_hangingTypeSignature = coerce False
|
||||||
}
|
}
|
||||||
, _conf_errorHandling = (_conf_errorHandling staticDefaultConfig)
|
, _conf_errorHandling = (_conf_errorHandling staticDefaultConfig)
|
||||||
{ _econf_ExactPrintFallback = coerce ExactPrintFallbackModeNever
|
{ _econf_ExactPrintFallback = coerce ExactPrintFallbackModeNever
|
||||||
|
|
|
@ -63,6 +63,7 @@ staticDefaultConfig = Config
|
||||||
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
||||||
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
||||||
, _lconfig_alignmentBreakOnMultiline = coerce True
|
, _lconfig_alignmentBreakOnMultiline = coerce True
|
||||||
|
, _lconfig_hangingTypeSignature = coerce False
|
||||||
}
|
}
|
||||||
, _conf_errorHandling = ErrorHandlingConfig
|
, _conf_errorHandling = ErrorHandlingConfig
|
||||||
{ _econf_produceOutputOnErrors = coerce False
|
{ _econf_produceOutputOnErrors = coerce False
|
||||||
|
@ -156,6 +157,7 @@ configParser = do
|
||||||
, _lconfig_columnAlignMode = mempty
|
, _lconfig_columnAlignMode = mempty
|
||||||
, _lconfig_alignmentLimit = mempty
|
, _lconfig_alignmentLimit = mempty
|
||||||
, _lconfig_alignmentBreakOnMultiline = mempty
|
, _lconfig_alignmentBreakOnMultiline = mempty
|
||||||
|
, _lconfig_hangingTypeSignature = mempty
|
||||||
}
|
}
|
||||||
, _conf_errorHandling = ErrorHandlingConfig
|
, _conf_errorHandling = ErrorHandlingConfig
|
||||||
{ _econf_produceOutputOnErrors = wrapLast $ falseToNothing outputOnErrors
|
{ _econf_produceOutputOnErrors = wrapLast $ falseToNothing outputOnErrors
|
||||||
|
|
|
@ -73,6 +73,17 @@ data CLayoutConfig f = LayoutConfig
|
||||||
-- short <- some more stuff
|
-- short <- some more stuff
|
||||||
-- that requires two lines
|
-- that requires two lines
|
||||||
-- loooooooong <- stuff
|
-- 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)
|
deriving (Generic)
|
||||||
|
|
||||||
|
|
|
@ -52,23 +52,39 @@ layoutSig lsig@(L _loc sig) = case sig of
|
||||||
let nameStr = Text.intercalate (Text.pack ", ") $ nameStrs
|
let nameStr = Text.intercalate (Text.pack ", ") $ nameStrs
|
||||||
typeDoc <- docSharedWrapper layoutType typ
|
typeDoc <- docSharedWrapper layoutType typ
|
||||||
hasComments <- hasAnyCommentsBelow lsig
|
hasComments <- hasAnyCommentsBelow lsig
|
||||||
docAlt
|
shouldBeHanging <- mAsk
|
||||||
$ [ docSeq
|
<&> _conf_layout
|
||||||
[ appSep $ docWrapNodeRest lsig $ docLit nameStr
|
.> _lconfig_hangingTypeSignature
|
||||||
, appSep $ docLit $ Text.pack "::"
|
.> confUnpack
|
||||||
, docForceSingleline typeDoc
|
if shouldBeHanging
|
||||||
]
|
then docSeq
|
||||||
| not hasComments
|
[ appSep $ docWrapNodeRest lsig $ docLit nameStr
|
||||||
]
|
, docSetBaseY $ docLines
|
||||||
++ [ docAddBaseY BrIndentRegular $ docPar
|
[ docCols
|
||||||
(docWrapNodeRest lsig $ docLit nameStr)
|
ColTyOpPrefix
|
||||||
( docCols
|
[ docLit $ Text.pack ":: "
|
||||||
ColTyOpPrefix
|
, docAddBaseY (BrIndentSpecial 3) $ typeDoc
|
||||||
[ docLit $ Text.pack ":: "
|
]
|
||||||
, docAddBaseY (BrIndentSpecial 3) $ typeDoc
|
]
|
||||||
|
]
|
||||||
|
else
|
||||||
|
docAlt
|
||||||
|
$ [ docSeq
|
||||||
|
[ appSep $ docWrapNodeRest lsig $ docLit nameStr
|
||||||
|
, appSep $ docLit $ Text.pack "::"
|
||||||
|
, docForceSingleline typeDoc
|
||||||
|
]
|
||||||
|
| not hasComments
|
||||||
|
]
|
||||||
|
++ [ docAddBaseY BrIndentRegular $ docPar
|
||||||
|
(docWrapNodeRest lsig $ docLit nameStr)
|
||||||
|
( docCols
|
||||||
|
ColTyOpPrefix
|
||||||
|
[ docLit $ Text.pack ":: "
|
||||||
|
, docAddBaseY (BrIndentSpecial 3) $ typeDoc
|
||||||
|
]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
)
|
|
||||||
]
|
|
||||||
InlineSig name (InlinePragma _ spec _arity phaseAct conlike) ->
|
InlineSig name (InlinePragma _ spec _arity phaseAct conlike) ->
|
||||||
docWrapNode lsig $ do
|
docWrapNode lsig $ do
|
||||||
nameStr <- lrdrNameToTextAnn name
|
nameStr <- lrdrNameToTextAnn name
|
||||||
|
|
Loading…
Reference in New Issue