Compare commits
2 Commits
d3d3b90558
...
d5f1deaa3d
Author | SHA1 | Date |
---|---|---|
|
d5f1deaa3d | |
|
b6da307ecc |
|
@ -61,7 +61,6 @@ data
|
|||
}
|
||||
|
||||
#test record single line layout
|
||||
#pending config flag is disabled for now
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
-- brittany { lconfig_allowSinglelineRecord: true }
|
||||
data MyRecord = forall a . Show a => MyCons { foo :: a -> a, i :: Int }
|
||||
|
@ -73,6 +72,15 @@ data MyRecord = forall a . Show a => Bar
|
|||
{ foo :: abittoolongbutnotvery -> abittoolongbutnotvery
|
||||
}
|
||||
|
||||
#test avoid single-line record if there are comments
|
||||
-- brittany { lconfig_allowSinglelineRecord: true }
|
||||
data MyRecord = MyRecord
|
||||
{ a :: Int
|
||||
-- ^ comment 1
|
||||
, b :: Int
|
||||
-- ^ comment 2
|
||||
}
|
||||
|
||||
#test record forall constraint multiline
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
data MyRecord
|
||||
|
|
|
@ -455,7 +455,9 @@ createDetailsDoc consNameStr details = case details of
|
|||
let ((fName1, fType1), fDocR) = case mkFieldDocs fields of
|
||||
(doc1:docR) -> (doc1, docR)
|
||||
_ -> error "cannot happen (TM)"
|
||||
allowSingleline <- mAsk <&> _conf_layout .> _lconfig_allowSinglelineRecord .> confUnpack
|
||||
allowSingleline <- do
|
||||
allowViaConf <- mAsk <&> _conf_layout .> _lconfig_allowSinglelineRecord .> confUnpack
|
||||
pure (allowViaConf && not (hasAnyCommentsBelow epAnn))
|
||||
docAddBaseY BrIndentRegular $ runFilteredAlternative $ do
|
||||
-- single-line: { i :: Int, b :: Bool }
|
||||
addAlternativeCond allowSingleline $ docSeq
|
||||
|
|
|
@ -942,9 +942,13 @@ layoutExpr lexpr@(L _ expr) = do
|
|||
++ showOutputable content
|
||||
++ "|]"
|
||||
)
|
||||
HsSpliceE{} -> do
|
||||
splice@HsSpliceE{} -> do
|
||||
-- TODO
|
||||
briDocByExactInlineOnly "HsSpliceE{}" lexpr
|
||||
let epAnnWithoutCommas = case GHC.getLoc lexpr of
|
||||
SrcSpanAnn (EpAnn anch (AnnListItem _) comms) srcLoc -> do
|
||||
SrcSpanAnn (EpAnn anch (AnnListItem []) comms) srcLoc
|
||||
x@(SrcSpanAnn EpAnnNotUsed _) -> x
|
||||
briDocByExactInlineOnly "HsSpliceE{}" (L epAnnWithoutCommas splice)
|
||||
HsProc{} -> do
|
||||
-- TODO
|
||||
briDocByExactInlineOnly "HsProc{}" lexpr
|
||||
|
|
|
@ -81,14 +81,20 @@ briDocByExactNoComment ast = do
|
|||
-- not contain any newlines. If this property is not met, the semantics
|
||||
-- depend on the @econf_AllowRiskyExactPrintUse@ config flag.
|
||||
briDocByExactInlineOnly
|
||||
:: ( ExactPrint.ExactPrint (GHC.XRec GhcPs a)
|
||||
, Data (GHC.XRec GhcPs a)
|
||||
-- :: ( ExactPrint.ExactPrint (GHC.XRec GhcPs a)
|
||||
-- , Data (GHC.XRec GhcPs a)
|
||||
-- , Data a
|
||||
-- , Data (GHC.Anno a)
|
||||
-- , Outputable (GHC.Anno a)
|
||||
-- )
|
||||
:: ( GHC.Anno a ~ GHC.SrcSpanAnn' (EpAnn ann)
|
||||
, ExactPrint.ExactPrint (GenLocated (GHC.SrcSpanAnn' (EpAnn ann)) a)
|
||||
, Data a
|
||||
, Data (GHC.Anno a)
|
||||
, Outputable (GHC.Anno a)
|
||||
)
|
||||
=> String
|
||||
-> GHC.XRec GhcPs a
|
||||
-> GenLocated (GHC.SrcSpanAnn' (EpAnn ann)) a
|
||||
-> ToBriDocM (BriDocNumbered)
|
||||
briDocByExactInlineOnly infoStr ast = do
|
||||
traceIfDumpConf "ast"
|
||||
|
|
Loading…
Reference in New Issue