Prepare implementation for `IndentPolicyLeft`

pull/66/head
Lennart Spitzner 2017-09-21 23:26:23 +02:00
parent fdd2f5f6dc
commit 4568bd3553
3 changed files with 978 additions and 975 deletions

View File

@ -191,7 +191,7 @@ data IndentPolicy = IndentPolicyLeft -- never create a new indentation at more
| IndentPolicyFree -- can create new indentations whereever | IndentPolicyFree -- can create new indentations whereever
| IndentPolicyMultiple -- can create indentations only | IndentPolicyMultiple -- can create indentations only
-- at any n * amount. -- at any n * amount.
deriving (Show, Generic, Data) deriving (Eq, Show, Generic, Data)
data AltChooser = AltChooserSimpleQuick -- always choose last alternative. data AltChooser = AltChooserSimpleQuick -- always choose last alternative.
-- leads to tons of sparsely filled -- leads to tons of sparsely filled

View File

@ -13,6 +13,7 @@ where
import Language.Haskell.Brittany.Internal.Types import Language.Haskell.Brittany.Internal.Types
import Language.Haskell.Brittany.Internal.LayouterBasics import Language.Haskell.Brittany.Internal.LayouterBasics
import Language.Haskell.Brittany.Internal.Config.Types
import RdrName ( RdrName(..) ) import RdrName ( RdrName(..) )
import GHC ( runGhc, GenLocated(L), moduleNameString, AnnKeywordId(..) ) import GHC ( runGhc, GenLocated(L), moduleNameString, AnnKeywordId(..) )
@ -30,7 +31,8 @@ import Language.Haskell.Brittany.Internal.Layouters.Type
layoutExpr :: ToBriDoc HsExpr layoutExpr :: ToBriDoc HsExpr
layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of layoutExpr lexpr@(L _ expr) = do
docWrapNode lexpr $ case expr of
HsVar vname -> do HsVar vname -> do
docLit =<< lrdrNameToTextAnn vname docLit =<< lrdrNameToTextAnn vname
HsUnboundVar var -> case var of HsUnboundVar var -> case var of

View File

@ -26,7 +26,8 @@ import {-# SOURCE #-} Language.Haskell.Brittany.Internal.Layouters.Expr
layoutStmt :: ToBriDoc' (StmtLR RdrName RdrName (LHsExpr RdrName)) layoutStmt :: ToBriDoc' (StmtLR RdrName RdrName (LHsExpr RdrName))
layoutStmt lstmt@(L _ stmt) = docWrapNode lstmt $ case stmt of layoutStmt lstmt@(L _ stmt) = do
docWrapNode lstmt $ case stmt of
LastStmt body False _ -> do LastStmt body False _ -> do
layoutExpr body layoutExpr body
BindStmt lPat expr _ _ _ -> do BindStmt lPat expr _ _ _ -> do
@ -57,8 +58,8 @@ layoutStmt lstmt@(L _ stmt) = docWrapNode lstmt $ case stmt of
[ appSep $ docLit $ Text.pack "let" [ appSep $ docLit $ Text.pack "let"
, docSetBaseAndIndent $ return bindDoc , docSetBaseAndIndent $ return bindDoc
] ]
, docAddBaseY BrIndentRegular , docAddBaseY BrIndentRegular $ docPar
$ docPar (docLit $ Text.pack "let") (docLit $ Text.pack "let")
(docSetBaseAndIndent $ return bindDoc) (docSetBaseAndIndent $ return bindDoc)
] ]
Just bindDocs -> docAlt Just bindDocs -> docAlt