Compare commits

..

No commits in common. "d5f1deaa3ddfaf504ed8f095c4afaa97db2e52b6" and "d3d3b90558dde367b47530a745acd382b84b218a" have entirely different histories.

4 changed files with 7 additions and 27 deletions

View File

@ -61,6 +61,7 @@ data
} }
#test record single line layout #test record single line layout
#pending config flag is disabled for now
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
-- brittany { lconfig_allowSinglelineRecord: true } -- brittany { lconfig_allowSinglelineRecord: true }
data MyRecord = forall a . Show a => MyCons { foo :: a -> a, i :: Int } data MyRecord = forall a . Show a => MyCons { foo :: a -> a, i :: Int }
@ -72,15 +73,6 @@ data MyRecord = forall a . Show a => Bar
{ foo :: abittoolongbutnotvery -> abittoolongbutnotvery { 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 #test record forall constraint multiline
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
data MyRecord data MyRecord

View File

@ -455,9 +455,7 @@ createDetailsDoc consNameStr details = case details of
let ((fName1, fType1), fDocR) = case mkFieldDocs fields of let ((fName1, fType1), fDocR) = case mkFieldDocs fields of
(doc1:docR) -> (doc1, docR) (doc1:docR) -> (doc1, docR)
_ -> error "cannot happen (TM)" _ -> error "cannot happen (TM)"
allowSingleline <- do allowSingleline <- mAsk <&> _conf_layout .> _lconfig_allowSinglelineRecord .> confUnpack
allowViaConf <- mAsk <&> _conf_layout .> _lconfig_allowSinglelineRecord .> confUnpack
pure (allowViaConf && not (hasAnyCommentsBelow epAnn))
docAddBaseY BrIndentRegular $ runFilteredAlternative $ do docAddBaseY BrIndentRegular $ runFilteredAlternative $ do
-- single-line: { i :: Int, b :: Bool } -- single-line: { i :: Int, b :: Bool }
addAlternativeCond allowSingleline $ docSeq addAlternativeCond allowSingleline $ docSeq

View File

@ -942,13 +942,9 @@ layoutExpr lexpr@(L _ expr) = do
++ showOutputable content ++ showOutputable content
++ "|]" ++ "|]"
) )
splice@HsSpliceE{} -> do HsSpliceE{} -> do
-- TODO -- TODO
let epAnnWithoutCommas = case GHC.getLoc lexpr of briDocByExactInlineOnly "HsSpliceE{}" lexpr
SrcSpanAnn (EpAnn anch (AnnListItem _) comms) srcLoc -> do
SrcSpanAnn (EpAnn anch (AnnListItem []) comms) srcLoc
x@(SrcSpanAnn EpAnnNotUsed _) -> x
briDocByExactInlineOnly "HsSpliceE{}" (L epAnnWithoutCommas splice)
HsProc{} -> do HsProc{} -> do
-- TODO -- TODO
briDocByExactInlineOnly "HsProc{}" lexpr briDocByExactInlineOnly "HsProc{}" lexpr

View File

@ -81,20 +81,14 @@ briDocByExactNoComment ast = do
-- not contain any newlines. If this property is not met, the semantics -- not contain any newlines. If this property is not met, the semantics
-- depend on the @econf_AllowRiskyExactPrintUse@ config flag. -- depend on the @econf_AllowRiskyExactPrintUse@ config flag.
briDocByExactInlineOnly briDocByExactInlineOnly
-- :: ( ExactPrint.ExactPrint (GHC.XRec GhcPs a) :: ( ExactPrint.ExactPrint (GHC.XRec GhcPs a)
-- , Data (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 a
, Data (GHC.Anno a) , Data (GHC.Anno a)
, Outputable (GHC.Anno a) , Outputable (GHC.Anno a)
) )
=> String => String
-> GenLocated (GHC.SrcSpanAnn' (EpAnn ann)) a -> GHC.XRec GhcPs a
-> ToBriDocM (BriDocNumbered) -> ToBriDocM (BriDocNumbered)
briDocByExactInlineOnly infoStr ast = do briDocByExactInlineOnly infoStr ast = do
traceIfDumpConf "ast" traceIfDumpConf "ast"