hindent 4.6.4 → 5.0.0
raw patch · 184 files changed
+215/−7450 lines, 184 filesdep ~basedep ~haskell-src-extsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, haskell-src-exts
API changes (from Hackage documentation)
- HIndent: chrisDone :: Style
- HIndent: cramer :: Style
- HIndent: fundamental :: Style
- HIndent: gibiansky :: Style
- HIndent: styles :: [Style]
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Alt
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Asst
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.BangType
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Binds
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Bracket
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ClassDecl
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ConDecl
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Context
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.DataOrNew
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Decl
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.DeclHead
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Deriving
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Exp
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ExportSpec
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ExportSpecList
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.FieldDecl
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.FieldUpdate
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.FunDep
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.GuardedRhs
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.IPBind
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ImportDecl
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ImportSpec
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ImportSpecList
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.InstDecl
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.InstHead
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.InstRule
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Kind
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Literal
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Match
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Module
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ModuleHead
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ModuleName
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.ModulePragma
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Name
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Overlap
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Pat
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.PatField
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.QName
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.QOp
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.QualConDecl
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.QualStmt
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Rhs
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Sign
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.SpecialCon
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Splice
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Stmt
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.TyVarBind
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.Type
- HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Annotated.Syntax.WarningText
- HIndent.Styles.ChrisDone: OpChainExp :: (Exp l) -> OpChainLink l
- HIndent.Styles.ChrisDone: OpChainLink :: (QOp l) -> OpChainLink l
- HIndent.Styles.ChrisDone: State :: State
- HIndent.Styles.ChrisDone: chrisDone :: Style
- HIndent.Styles.ChrisDone: contextualGuardedRhs :: GuardedRhs NodeInfo -> Printer t ()
- HIndent.Styles.ChrisDone: data OpChainLink l
- HIndent.Styles.ChrisDone: data State
- HIndent.Styles.ChrisDone: decl :: Decl NodeInfo -> Printer s ()
- HIndent.Styles.ChrisDone: dependOrNewline :: Printer t () -> Exp NodeInfo -> (Exp NodeInfo -> Printer t ()) -> Printer t ()
- HIndent.Styles.ChrisDone: exp :: Exp NodeInfo -> Printer t ()
- HIndent.Styles.ChrisDone: fieldupdate :: FieldUpdate NodeInfo -> Printer t ()
- HIndent.Styles.ChrisDone: fitsInColumnLimit :: Printer t a -> Printer t (Bool, PrintState t)
- HIndent.Styles.ChrisDone: fitsOnOneLine :: MonadState (PrintState s) m => m a -> m (Bool, PrintState s)
- HIndent.Styles.ChrisDone: flattenOpChain :: Exp l -> [OpChainLink l]
- HIndent.Styles.ChrisDone: guardedalt :: GuardedRhs NodeInfo -> Printer t ()
- HIndent.Styles.ChrisDone: guardedrhs :: GuardedRhs NodeInfo -> Printer t ()
- HIndent.Styles.ChrisDone: infixApp :: Exp NodeInfo -> Exp NodeInfo -> QOp NodeInfo -> Exp NodeInfo -> Maybe Int64 -> Printer s ()
- HIndent.Styles.ChrisDone: instance GHC.Show.Show l => GHC.Show.Show (HIndent.Styles.ChrisDone.OpChainLink l)
- HIndent.Styles.ChrisDone: isFlat :: Exp NodeInfo -> Bool
- HIndent.Styles.ChrisDone: isShort :: (Pretty ast) => ast NodeInfo -> Printer t (Bool, PrintState t)
- HIndent.Styles.ChrisDone: isSmall :: MonadState (PrintState t) m => m a -> m (Bool, PrintState t)
- HIndent.Styles.ChrisDone: isSmallFitting :: MonadState (PrintState t) m => m a -> m (Bool, PrintState t)
- HIndent.Styles.ChrisDone: multi :: Pretty ast => Int64 -> [ast NodeInfo] -> Bool -> Printer t ()
- HIndent.Styles.ChrisDone: rhs :: Rhs NodeInfo -> Printer t ()
- HIndent.Styles.ChrisDone: sandboxNonOverflowing :: Pretty ast => [ast NodeInfo] -> Printer t ((Bool, Bool), PrintState t)
- HIndent.Styles.ChrisDone: sandboxSingles :: Pretty ast => [ast NodeInfo] -> Printer t (Bool, PrintState t)
- HIndent.Styles.ChrisDone: shortName :: Int64
- HIndent.Styles.ChrisDone: smallColumnLimit :: Int64
- HIndent.Styles.ChrisDone: stmt :: Stmt NodeInfo -> Printer t ()
- HIndent.Styles.ChrisDone: types :: Type NodeInfo -> Printer s ()
- HIndent.Styles.ChrisDone: unguardedalt :: Rhs NodeInfo -> Printer t ()
- HIndent.Styles.ChrisDone: unguardedrhs :: Rhs NodeInfo -> Printer t ()
- HIndent.Styles.Cramer: cramer :: Style
- HIndent.Styles.Cramer: instance GHC.Classes.Eq HIndent.Styles.Cramer.LineBreak
- HIndent.Styles.Cramer: instance GHC.Enum.Enum HIndent.Styles.Cramer.LineBreak
- HIndent.Styles.Cramer: instance GHC.Show.Show HIndent.Styles.Cramer.LineBreak
- HIndent.Styles.Cramer: instance GHC.Show.Show HIndent.Styles.Cramer.State
- HIndent.Styles.Fundamental: State :: State
- HIndent.Styles.Fundamental: data State
- HIndent.Styles.Fundamental: fundamental :: Style
- HIndent.Styles.Gibiansky: State :: Bool -> Bool -> State
- HIndent.Styles.Gibiansky: [gibianskyForceSingleLine] :: State -> Bool
- HIndent.Styles.Gibiansky: [gibianskyLetBind] :: State -> Bool
- HIndent.Styles.Gibiansky: alt :: Extend Alt
- HIndent.Styles.Gibiansky: appExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: applicativeExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: astStartLine :: Annotated ast => ast NodeInfo -> Int
- HIndent.Styles.Gibiansky: attemptSingleLine :: Printer State a -> Printer State a -> Printer State a
- HIndent.Styles.Gibiansky: breakCommentLines :: Int -> String -> [String]
- HIndent.Styles.Gibiansky: caseExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: collectTypes :: Type l -> [Type l]
- HIndent.Styles.Gibiansky: commaAfterComment :: ComInfoLocation -> Printer State ()
- HIndent.Styles.Gibiansky: commentContent :: Comment -> String
- HIndent.Styles.Gibiansky: commentPreprocessor :: MonadState (PrintState s) m => [Comment] -> m [Comment]
- HIndent.Styles.Gibiansky: commentSrcSpan :: Comment -> SrcSpan
- HIndent.Styles.Gibiansky: condecls :: Extend ConDecl
- HIndent.Styles.Gibiansky: context :: Extend Context
- HIndent.Styles.Gibiansky: data State
- HIndent.Styles.Gibiansky: decls :: Extend Decl
- HIndent.Styles.Gibiansky: derivings :: Extend Deriving
- HIndent.Styles.Gibiansky: doExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: dollarExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: dropTrailingNewlines :: String -> String
- HIndent.Styles.Gibiansky: exportList :: Extend ExportSpecList
- HIndent.Styles.Gibiansky: exprs :: Extend Exp
- HIndent.Styles.Gibiansky: fieldUpdate :: Extend FieldUpdate
- HIndent.Styles.Gibiansky: fixSpans :: NodeInfo -> NodeInfo
- HIndent.Styles.Gibiansky: funBody :: [Pat NodeInfo] -> Rhs NodeInfo -> Maybe (Binds NodeInfo) -> Printer State ()
- HIndent.Styles.Gibiansky: gibiansky :: Style
- HIndent.Styles.Gibiansky: guardedRhs :: Extend GuardedRhs
- HIndent.Styles.Gibiansky: hasComments :: Foldable ast => ast NodeInfo -> Bool
- HIndent.Styles.Gibiansky: ifExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: imp :: Extend ImportDecl
- HIndent.Styles.Gibiansky: indentOnce :: Printer s ()
- HIndent.Styles.Gibiansky: indentSpaces :: Integral a => a
- HIndent.Styles.Gibiansky: isDoBlock :: Rhs l -> Bool
- HIndent.Styles.Gibiansky: keepingColumn :: Printer State () -> Printer State ()
- HIndent.Styles.Gibiansky: lambdaCaseExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: lambdaExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: letExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: lineBreakAfterRhs :: NodeInfo -> Exp NodeInfo -> Bool
- HIndent.Styles.Gibiansky: lineDelta :: (Annotated ast1, Annotated ast2) => ast1 NodeInfo -> ast2 NodeInfo -> Int
- HIndent.Styles.Gibiansky: listExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: maxSingleLineExports :: Integral a => a
- HIndent.Styles.Gibiansky: modl :: Extend Module
- HIndent.Styles.Gibiansky: moduleHead :: Extend ModuleHead
- HIndent.Styles.Gibiansky: multiIfExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: multiLineList :: [Exp NodeInfo] -> Printer State ()
- HIndent.Styles.Gibiansky: onSeparateLines :: (Pretty ast, Annotated ast) => [ast NodeInfo] -> Printer State ()
- HIndent.Styles.Gibiansky: onSeparateLines' :: Annotated ast => (ast NodeInfo -> Printer State ()) -> [ast NodeInfo] -> Printer State ()
- HIndent.Styles.Gibiansky: opExpr :: Exp NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: pat :: Extend Pat
- HIndent.Styles.Gibiansky: pragmas :: Extend ModulePragma
- HIndent.Styles.Gibiansky: prettyColLength :: (Integral a, Pretty ast) => ast NodeInfo -> Printer State a
- HIndent.Styles.Gibiansky: prettyCommentCallbacks :: (Pretty ast, MonadState (PrintState s) m) => ast NodeInfo -> (ComInfoLocation -> m ()) -> m ()
- HIndent.Styles.Gibiansky: qualConDecl :: Extend QualConDecl
- HIndent.Styles.Gibiansky: recUpdateExpr :: Foldable f => [f NodeInfo] -> Printer State () -> [(ComInfoLocation -> Printer State ()) -> Printer State ()] -> Printer State ()
- HIndent.Styles.Gibiansky: rhsRest :: Pretty ast => ast NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: rhss :: Extend Rhs
- HIndent.Styles.Gibiansky: sameLine :: (Annotated ast, Annotated ast') => ast NodeInfo -> ast' NodeInfo -> Bool
- HIndent.Styles.Gibiansky: singleLineList :: Pretty a => [a NodeInfo] -> Printer State ()
- HIndent.Styles.Gibiansky: skipFollowingNewline :: Decl l -> Bool
- HIndent.Styles.Gibiansky: stmts :: Extend Stmt
- HIndent.Styles.Gibiansky: typ :: Extend Type
- HIndent.Styles.Gibiansky: type Extend f = f NodeInfo -> Printer State ()
- HIndent.Styles.Gibiansky: userGets :: (State -> a) -> Printer State a
- HIndent.Styles.Gibiansky: userModify :: (State -> State) -> Printer State ()
- HIndent.Styles.Gibiansky: writeCaseAlts :: [Alt NodeInfo] -> Printer State ()
- HIndent.Styles.Gibiansky: writeTuple :: Pretty ast => Boxed -> [ast NodeInfo] -> Printer State ()
- HIndent.Styles.Gibiansky: writeWhereBinds :: Binds NodeInfo -> Printer State ()
+ HIndent.Pretty: indentedBlock :: MonadState (PrintState s) m => m a -> m a
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Alt
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Asst
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.BangType
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Binds
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Bracket
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ClassDecl
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ConDecl
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Context
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.DataOrNew
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Decl
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.DeclHead
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Deriving
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Exp
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ExportSpec
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ExportSpecList
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.FieldDecl
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.FieldUpdate
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.FunDep
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.GuardedRhs
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.IPBind
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ImportDecl
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ImportSpec
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ImportSpecList
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.InjectivityInfo
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.InstDecl
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.InstHead
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.InstRule
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Kind
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Literal
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Match
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Module
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ModuleHead
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ModuleName
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ModulePragma
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Name
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Overlap
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Pat
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.PatField
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.QName
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.QOp
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.QualConDecl
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.QualStmt
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.ResultSig
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Rhs
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Sign
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.SpecialCon
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Splice
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Stmt
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.TyVarBind
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Type
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.Unpackedness
+ HIndent.Pretty: instance HIndent.Pretty.Pretty Language.Haskell.Exts.Syntax.WarningText
+ HIndent.Styles.JohanTibell: OpChainExp :: (Exp l) -> OpChainLink l
+ HIndent.Styles.JohanTibell: OpChainLink :: (QOp l) -> OpChainLink l
+ HIndent.Styles.JohanTibell: data OpChainLink l
+ HIndent.Styles.JohanTibell: flattenOpChain :: Exp l -> [OpChainLink l]
+ HIndent.Styles.JohanTibell: infixApp :: Exp NodeInfo -> Exp NodeInfo -> QOp NodeInfo -> Exp NodeInfo -> Maybe Int64 -> Printer s ()
+ HIndent.Styles.JohanTibell: instance GHC.Show.Show l => GHC.Show.Show (HIndent.Styles.JohanTibell.OpChainLink l)
Files
- README.md +4/−190
- elisp/hindent.el +12/−0
- hindent.cabal +2/−12
- src/HIndent.hs +2/−11
- src/HIndent/Comments.hs +1/−1
- src/HIndent/Pretty.hs +72/−52
- src/HIndent/Styles/ChrisDone.hs +0/−528
- src/HIndent/Styles/Cramer.hs +0/−908
- src/HIndent/Styles/Fundamental.hs +0/−23
- src/HIndent/Styles/Gibiansky.hs +0/−1155
- src/HIndent/Styles/JohanTibell.hs +49/−2
- src/main/Main.hs +68/−50
- src/main/TestGenerate.hs +2/−1
- test/Spec.hs +3/−2
- test/chris-done/expected/1.exp +0/−11
- test/chris-done/expected/10.exp +0/−39
- test/chris-done/expected/11.exp +0/−56
- test/chris-done/expected/12.exp +0/−123
- test/chris-done/expected/13.exp +0/−27
- test/chris-done/expected/14.exp +0/−10
- test/chris-done/expected/15.exp +0/−42
- test/chris-done/expected/16.exp +0/−3
- test/chris-done/expected/17.exp +0/−3
- test/chris-done/expected/18.exp +0/−19
- test/chris-done/expected/19.exp +0/−15
- test/chris-done/expected/2.exp +0/−30
- test/chris-done/expected/20.exp +0/−3
- test/chris-done/expected/3.exp +0/−45
- test/chris-done/expected/4.exp +0/−51
- test/chris-done/expected/5.exp +0/−45
- test/chris-done/expected/6.exp +0/−45
- test/chris-done/expected/7.exp +0/−23
- test/chris-done/expected/8.exp +0/−29
- test/chris-done/expected/9.exp +0/−16
- test/chris-done/tests/1.test +0/−11
- test/chris-done/tests/10.test +0/−41
- test/chris-done/tests/11.test +0/−46
- test/chris-done/tests/12.test +0/−86
- test/chris-done/tests/13.test +0/−29
- test/chris-done/tests/14.test +0/−10
- test/chris-done/tests/15.test +0/−21
- test/chris-done/tests/16.test +0/−3
- test/chris-done/tests/17.test +0/−4
- test/chris-done/tests/18.test +0/−11
- test/chris-done/tests/19.test +0/−16
- test/chris-done/tests/2.test +0/−32
- test/chris-done/tests/20.test +0/−3
- test/chris-done/tests/3.test +0/−38
- test/chris-done/tests/4.test +0/−36
- test/chris-done/tests/5.test +0/−27
- test/chris-done/tests/6.test +0/−41
- test/chris-done/tests/7.test +0/−30
- test/chris-done/tests/8.test +0/−24
- test/chris-done/tests/9.test +0/−19
- test/fundamental/expected/1.exp +0/−11
- test/fundamental/expected/10.exp +0/−63
- test/fundamental/expected/11.exp +0/−71
- test/fundamental/expected/12.exp +0/−123
- test/fundamental/expected/13.exp +0/−39
- test/fundamental/expected/14.exp +0/−17
- test/fundamental/expected/15.exp +0/−63
- test/fundamental/expected/16.exp +0/−5
- test/fundamental/expected/17.exp +0/−3
- test/fundamental/expected/18.exp +0/−31
- test/fundamental/expected/19.exp +0/−23
- test/fundamental/expected/2.exp +0/−29
- test/fundamental/expected/3.exp +0/−62
- test/fundamental/expected/4.exp +0/−51
- test/fundamental/expected/5.exp +0/−45
- test/fundamental/expected/6.exp +0/−79
- test/fundamental/expected/7.exp +0/−43
- test/fundamental/expected/8.exp +0/−50
- test/fundamental/expected/9.exp +0/−22
- test/fundamental/tests/1.test +0/−11
- test/fundamental/tests/10.test +0/−41
- test/fundamental/tests/11.test +0/−46
- test/fundamental/tests/12.test +0/−86
- test/fundamental/tests/13.test +0/−29
- test/fundamental/tests/14.test +0/−10
- test/fundamental/tests/15.test +0/−21
- test/fundamental/tests/16.test +0/−3
- test/fundamental/tests/17.test +0/−4
- test/fundamental/tests/18.test +0/−11
- test/fundamental/tests/19.test +0/−16
- test/fundamental/tests/2.test +0/−32
- test/fundamental/tests/3.test +0/−38
- test/fundamental/tests/4.test +0/−36
- test/fundamental/tests/5.test +0/−27
- test/fundamental/tests/6.test +0/−41
- test/fundamental/tests/7.test +0/−30
- test/fundamental/tests/8.test +0/−24
- test/fundamental/tests/9.test +0/−19
- test/gibiansky/expected/1.exp +0/−11
- test/gibiansky/expected/10.exp +0/−44
- test/gibiansky/expected/11.exp +0/−53
- test/gibiansky/expected/12.exp +0/−93
- test/gibiansky/expected/13.exp +0/−30
- test/gibiansky/expected/14.exp +0/−10
- test/gibiansky/expected/15.exp +0/−39
- test/gibiansky/expected/16.exp +0/−3
- test/gibiansky/expected/17.exp +0/−3
- test/gibiansky/expected/18.exp +0/−17
- test/gibiansky/expected/19.exp +0/−18
- test/gibiansky/expected/2.exp +0/−37
- test/gibiansky/expected/20.exp +0/−2
- test/gibiansky/expected/21.exp +0/−5
- test/gibiansky/expected/22.exp +0/−4
- test/gibiansky/expected/23.exp +0/−11
- test/gibiansky/expected/24.exp +0/−19
- test/gibiansky/expected/25.exp +0/−8
- test/gibiansky/expected/26.exp +0/−1
- test/gibiansky/expected/27.exp +0/−27
- test/gibiansky/expected/28.exp +0/−17
- test/gibiansky/expected/29.exp +0/−29
- test/gibiansky/expected/3.exp +0/−45
- test/gibiansky/expected/30.exp +0/−22
- test/gibiansky/expected/31.exp +0/−58
- test/gibiansky/expected/32.exp +0/−39
- test/gibiansky/expected/33.exp +0/−46
- test/gibiansky/expected/34.exp +0/−17
- test/gibiansky/expected/35.exp +0/−3
- test/gibiansky/expected/36.exp +0/−60
- test/gibiansky/expected/37.exp +0/−5
- test/gibiansky/expected/38.exp +0/−9
- test/gibiansky/expected/39.exp +0/−19
- test/gibiansky/expected/4.exp +0/−39
- test/gibiansky/expected/40.exp +0/−3
- test/gibiansky/expected/41.exp +0/−35
- test/gibiansky/expected/42.exp +0/−4
- test/gibiansky/expected/43.exp +0/−8
- test/gibiansky/expected/44.exp +0/−3
- test/gibiansky/expected/45.exp +0/−2
- test/gibiansky/expected/46.exp +0/−7
- test/gibiansky/expected/5.exp +0/−30
- test/gibiansky/expected/6.exp +0/−48
- test/gibiansky/expected/7.exp +0/−34
- test/gibiansky/expected/8.exp +0/−29
- test/gibiansky/expected/9.exp +0/−20
- test/gibiansky/tests/1.test +0/−11
- test/gibiansky/tests/10.test +0/−41
- test/gibiansky/tests/11.test +0/−43
- test/gibiansky/tests/12.test +0/−86
- test/gibiansky/tests/13.test +0/−28
- test/gibiansky/tests/14.test +0/−10
- test/gibiansky/tests/15.test +0/−21
- test/gibiansky/tests/16.test +0/−3
- test/gibiansky/tests/17.test +0/−4
- test/gibiansky/tests/18.test +0/−11
- test/gibiansky/tests/19.test +0/−16
- test/gibiansky/tests/2.test +0/−32
- test/gibiansky/tests/20.test +0/−2
- test/gibiansky/tests/21.test +0/−5
- test/gibiansky/tests/22.test +0/−4
- test/gibiansky/tests/23.test +0/−11
- test/gibiansky/tests/24.test +0/−18
- test/gibiansky/tests/25.test +0/−8
- test/gibiansky/tests/26.test +0/−1
- test/gibiansky/tests/27.test +0/−28
- test/gibiansky/tests/28.test +0/−17
- test/gibiansky/tests/29.test +0/−29
- test/gibiansky/tests/3.test +0/−38
- test/gibiansky/tests/30.test +0/−25
- test/gibiansky/tests/31.test +0/−48
- test/gibiansky/tests/32.test +0/−37
- test/gibiansky/tests/33.test +0/−46
- test/gibiansky/tests/34.test +0/−17
- test/gibiansky/tests/35.test +0/−2
- test/gibiansky/tests/36.test +0/−46
- test/gibiansky/tests/37.test +0/−5
- test/gibiansky/tests/38.test +0/−9
- test/gibiansky/tests/39.test +0/−19
- test/gibiansky/tests/4.test +0/−36
- test/gibiansky/tests/40.test +0/−3
- test/gibiansky/tests/41.test +0/−7
- test/gibiansky/tests/42.test +0/−4
- test/gibiansky/tests/43.test +0/−7
- test/gibiansky/tests/44.test +0/−3
- test/gibiansky/tests/45.test +0/−2
- test/gibiansky/tests/46.test +0/−7
- test/gibiansky/tests/5.test +0/−27
- test/gibiansky/tests/6.test +0/−41
- test/gibiansky/tests/7.test +0/−30
- test/gibiansky/tests/8.test +0/−24
- test/gibiansky/tests/9.test +0/−19
README.md view
@@ -1,15 +1,11 @@- # hindent [](https://hackage.haskell.org/package/hindent) [](https://travis-ci.org/chrisdone/hindent) Extensible Haskell pretty printer. Both a library and an-executable. Currently a work in progress (see-[FIXME items](https://github.com/chrisdone/hindent/blob/master/src/HIndent/Pretty.hs)).--[Documentation](http://chrisdone.github.io/hindent/)+executable. ## Install - $ stack build --copy-bins+ $ stack install ## Usage @@ -17,8 +13,6 @@ $ cat path/to/sourcefile.hs | hindent > outfile.hs - hindent: arguments: --style [fundamental|chris-done|johan-tibell|gibiansky|cramer]- ## Emacs In@@ -38,22 +32,13 @@ (add-hook 'haskell-mode-hook #'hindent-mode) ``` -By default it uses the style called `fundamental`, if you want to use-another, `johan-tibell`, run `M-x customize-variable-hindent-style`. If you want to configure per-project, make a file-called `.dir-locals.el` in the project root directory like this:--``` lisp-((nil . ((hindent-style . "johan-tibell"))))-```- ## Vim The `'formatprg'` option lets you use an external program (like hindent) to format your text. Put the following line into ~/.vim/ftplugin/haskell.vim to set this option for Haskell files: - setlocal formatprg=hindent\ --style\ chris-done+ setlocal formatprg=hindent Then you can format with hindent using `gq`. Read `:help gq` and `help 'formatprg'` for more details.@@ -63,176 +48,5 @@ ## Atom -Basic support is provided through [atom/hindent.coffee](https://github.com/chrisdone/hindent/blob/master/atom/hindent.coffee),-which adds hindent to atom menu with each available style. Mode should be installed as package into `.atom\packages\${PACKAGE_NAME}`,+Basic support is provided through [atom/hindent.coffee](https://github.com/chrisdone/hindent/blob/master/atom/hindent.coffee). Mode should be installed as package into `.atom\packages\${PACKAGE_NAME}`, here is simple example of atom [package](https://github.com/Heather/atom-hindent).--## Contributing your own printer style--This package comes with a basic fundamental pretty printer, which is-probably not desirable to use.--It comes with other styles implemented on top of this fundamental-printer, in the modules in `HIndent.Styles.*`.--Make a module `HIndent.Styles.YourName` in which to place the printer.--To define your own, see-[HIndent.Styles.Fundamental](https://github.com/chrisdone/hindent/blob/master/src/HIndent/Styles/Fundamental.hs)-for a starting point. This module defines a blank style, adds no-additional extensions. Customizations are specified via the-`styleExtenders` property. See-[HIndent.Styles.ChrisDone](https://github.com/chrisdone/hindent/blob/master/src/HIndent/Styles/ChrisDone.hs)-for an example of a non-trivial style.--Useful combinators can be found in-[HIndent.Pretty](https://github.com/chrisdone/hindent/blob/master/src/HIndent/Pretty.hs)-for defining printers. When you want to use a fundamental printer, use-`prettyNoExt` instead of `pretty`. Comments will still be inserted by-`prettyNoExt`.--If you want to contribute it to the package, add it to the list of-styles in-[HIndent](https://github.com/chrisdone/hindent/blob/master/src/HIndent.hs)-and export it, and open a pull request. Use-[the Erlang git commit guide](https://github.com/erlang/otp/wiki/Writing-good-commit-messages)-for your commits.--## Remaining issues--* Add test suite.-* Flesh out more obscure parts of the AST.-* Improve comment re-insertion.-* Possibly: Support formatting whole modules.-* Implement some operator-specific layouts: e.g.-- Foo <$> foo- <*> bar- <*> mu--## Example--Input code:--``` haskell-foo = do print "OK, go"; foo (foo bar) -- Yep.- (if bar then bob else pif) (case mu {- cool -} zot of- Just x -> return (); Nothing -> do putStrLn "yay"; return 1) bill -- Etc- where potato Cakes {} = 2 * x foo * bar / 5-```--### Fundamental--This is an intentionally very dumb style that demands extension.--``` haskell-foo =- do print- "OK, go"- foo- (foo- bar)- (if bar- then bob- else pif)- (case mu {- cool -}- zot of- Just x ->- return- ()- Nothing ->- do putStrLn- "yay"- return- 1)- bill -- Etc- where potato Cakes{} =- 2 * x- foo * bar / 5-```--### Johan Tibell--Documented in-[the style guide](https://github.com/tibbe/haskell-style-guide).-This printer style uses some simple heuristics in deciding when to go-to a new line or not, and custom handling of do, if, case alts, rhs,-etc.--``` haskell-foo = do- print "OK, go"- foo- (foo bar)- (if bar- then bob- else pif)- (case mu {- cool -} zot of- Just x ->- return ()- Nothing -> do- putStrLn "yay"- return 1)- bill -- Etc- where- potato Cakes{} =- 2 * x foo * bar / 5-```--### Chris Done--My style is documented in-[the style guide](https://github.com/chrisdone/haskell-style-guide).-This printer style uses some simple heuristics in deciding when to go-to a new line or not.--``` haskell-foo =- do print "OK, go"- foo (foo bar)- (if bar- then bob- else pif)- (case mu {- cool -} zot of- Just x -> return ()- Nothing ->- do putStrLn "yay"- return 1)- bill -- Etc- where potato Cakes{} = 2 * x foo * bar / 5-```--### Andrew Gibiansky--``` haskell-foo = do- print "OK, go"- foo (foo bar) -- Yep.- (if bar- then bob- else pif) (case mu {- cool -} zot of- Just x -> return ()- Nothing -> do- putStrLn "yay"- return 1) bill -- Etc-- where- potato Cakes{} = 2 * x foo * bar / 5-```--### Enno Cramer--``` haskell-foo = do- print "OK, go"- foo (foo bar)- (if bar then bob else pif)- (case mu {- cool -} zot of- Just x -> return ()- Nothing -> do- putStrLn "yay"- return 1)- bill -- Etc- where- potato Cakes{} = 2 * x foo * bar / 5-```
elisp/hindent.el view
@@ -63,6 +63,14 @@ :type 'string :safe #'stringp) +(defcustom hindent-line-length+ nil+ "Optionally override the line length of the formatting style."+ :group 'haskell+ :type '(choice (const :tag "From style" nil)+ (integer :tag "Override" 80))+ :safe (lambda (val) (or (integerp val) (not val))))+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Interactive functions @@ -147,6 +155,10 @@ nil "--style" hindent-style)+ (when hindent-line-length+ (list "--line-length"+ (number-to-string+ hindent-line-length))) (hindent-extra-arguments))))) (cond ((= ret 1)
hindent.cabal view
@@ -1,5 +1,5 @@ name: hindent-version: 4.6.4+version: 5.0.0 synopsis: Extensible Haskell pretty printer description: Extensible Haskell pretty printer. Both a library and an executable. .@@ -18,12 +18,6 @@ data-files: elisp/hindent.el extra-source-files: README.md benchmarks/BigDeclarations.hs- test/chris-done/expected/*.exp- test/chris-done/tests/*.test- test/gibiansky/expected/*.exp- test/gibiansky/tests/*.test- test/fundamental/expected/*.exp- test/fundamental/tests/*.test test/johan-tibell/expected/*.exp test/johan-tibell/tests/*.test @@ -38,14 +32,10 @@ HIndent.Types HIndent.Pretty HIndent.Comments- HIndent.Styles.Fundamental- HIndent.Styles.ChrisDone HIndent.Styles.JohanTibell- HIndent.Styles.Gibiansky- HIndent.Styles.Cramer build-depends: base >= 4.7 && <5 , containers- , haskell-src-exts >= 1.17+ , haskell-src-exts >= 1.18 , monad-loops , mtl , text
src/HIndent.hs view
@@ -10,12 +10,7 @@ ,parseMode -- * Style ,Style(..)- ,styles- ,chrisDone ,johanTibell- ,fundamental- ,gibiansky- ,cramer -- * Testing ,test ,testFile@@ -27,10 +22,6 @@ import HIndent.Comments import HIndent.Pretty-import HIndent.Styles.ChrisDone (chrisDone)-import HIndent.Styles.Cramer (cramer)-import HIndent.Styles.Fundamental (fundamental)-import HIndent.Styles.Gibiansky (gibiansky) import HIndent.Styles.JohanTibell (johanTibell) import HIndent.Types @@ -49,7 +40,7 @@ import Data.Text.Lazy.Builder (Builder) import qualified Data.Text.Lazy.Builder as T import qualified Data.Text.Lazy.IO as T-import Language.Haskell.Exts.Annotated hiding (Style, prettyPrint, Pretty, style, parse)+import Language.Haskell.Exts hiding (Style, prettyPrint, Pretty, style, parse) data CodeBlock = HaskellSource Text | CPPDirectives Text@@ -232,7 +223,7 @@ -- | Styles list, useful for programmatically choosing. styles :: [Style] styles =- [fundamental,chrisDone,johanTibell,gibiansky,cramer]+ [johanTibell] -- | Default extensions. defaultExtensions :: [Extension]
src/HIndent/Comments.hs view
@@ -12,7 +12,7 @@ import qualified Data.Map.Strict as M import Data.Traversable import HIndent.Types-import Language.Haskell.Exts.Annotated hiding (Style,prettyPrint,Pretty,style,parse)+import Language.Haskell.Exts hiding (Style,prettyPrint,Pretty,style,parse) -- Order by start of span, larger spans before smaller spans. newtype OrderByStart =
src/HIndent/Pretty.hs view
@@ -43,6 +43,7 @@ , braces -- * Indentation , indented+ , indentedBlock , column , getColumn , getLineNum@@ -70,6 +71,7 @@ import Data.Int import Data.List import Data.Maybe+import Data.Foldable (traverse_) import Data.Monoid hiding (Alt) import Data.Text (Text) import qualified Data.Text as T@@ -78,8 +80,8 @@ import qualified Data.Text.Lazy.Builder as T import Data.Text.Lazy.Builder.Int import Data.Typeable-import qualified Language.Haskell.Exts.Annotated as P-import Language.Haskell.Exts.Annotated.Syntax+import qualified Language.Haskell.Exts as P+import Language.Haskell.Exts.Syntax import Language.Haskell.Exts.SrcLoc import Prelude hiding (exp) @@ -193,6 +195,11 @@ modify (\s -> s {psIndentLevel = level}) return m +indentedBlock :: MonadState (PrintState s) m => m a -> m a+indentedBlock p =+ do indentSpaces <- getIndentSpaces+ indented indentSpaces p+ -- | Print all the printers separated by spaces. spaced :: MonadState (PrintState s) m => [m ()] -> m () spaced = inter space@@ -484,8 +491,12 @@ brackets (commas (map pretty ps)) PParen _ e -> parens (pretty e) PRec _ qname fields ->- depend (pretty qname)- (braces (commas (map pretty fields)))+ do indentSpaces <- getIndentSpaces+ depend (do pretty qname+ space)+ (braces (prefixedLined ","+ (map (indented indentSpaces . pretty) fields)))+ PAsPat _ n p -> depend (do pretty n write "@")@@ -522,7 +533,10 @@ prettyInfixOp :: MonadState (PrintState s) m => QName NodeInfo -> m () prettyInfixOp x = case x of- Qual{} -> do write "`"; pretty' x; write "`"+ Qual _ mn n ->+ case n of+ Ident _ i -> do write "`"; pretty mn; write "."; string i; write "`";+ Symbol _ s -> do pretty mn; write "."; string s; UnQual _ n -> case n of Ident _ i -> string ("`" ++ i ++ "`")@@ -571,8 +585,9 @@ parens (do pretty ty write " :: " pretty k)- TyBang _ bangty right ->- do pretty bangty+ TyBang _ bangty unpackty right ->+ do pretty unpackty+ pretty bangty pretty right TyEquals _ left right -> do pretty left@@ -638,8 +653,7 @@ (do pretty e write " of") newline- indentSpaces <- getIndentSpaces- indented indentSpaces (lined (map (withCaseContext True . pretty) alts))+ indentedBlock (lined (map (withCaseContext True . pretty) alts)) exp (Do _ stmts) = depend (write "do ") (lined (map pretty stmts))@@ -675,17 +689,15 @@ space) (pretty op)) exp (RecConstr _ n fs) =- do indentSpaces <- getIndentSpaces- depend (do pretty n- space)- (braces (prefixedLined ","- (map (indented indentSpaces . pretty) fs)))+ depend (do pretty n+ space)+ (braces (prefixedLined ","+ (map (indentedBlock . pretty) fs))) exp (RecUpdate _ n fs) =- do indentSpaces <- getIndentSpaces- depend (do pretty n- space)- (braces (prefixedLined ","- (map (indented indentSpaces . pretty) fs)))+ depend (do pretty n+ space)+ (braces (prefixedLined ","+ (map (indentedBlock . pretty) fs))) exp (EnumFrom _ e) = brackets (do pretty e write " ..")@@ -731,9 +743,8 @@ write "|")) exp (LCase _ alts) = do write "\\case"- indentSpaces <- getIndentSpaces newline- indented indentSpaces (lined (map (withCaseContext True . pretty) alts))+ indentedBlock (lined (map (withCaseContext True . pretty) alts)) exp (MultiIf _ alts) = withCaseContext True@@ -803,24 +814,21 @@ decl (PatBind _ pat rhs mbinds) = do pretty pat withCaseContext False (pretty rhs)- indentSpaces <- getIndentSpaces case mbinds of Nothing -> return () Just binds -> do newline- indented indentSpaces- (depend (write "where ")- (pretty binds))+ indentedBlock (depend (write "where ")+ (pretty binds)) decl (InstDecl _ moverlap dhead decls) =- do indentSpaces <- getIndentSpaces- depend (write "instance ")+ do depend (write "instance ") (depend (maybeOverlap moverlap) (depend (pretty dhead) (unless (null (fromMaybe [] decls)) (write " where")))) unless (null (fromMaybe [] decls)) (do newline- indented indentSpaces (lined (map pretty (fromMaybe [] decls))))+ indentedBlock (lined (map pretty (fromMaybe [] decls)))) decl (SpliceDecl _ e) = pretty e decl (TypeSig _ names ty) = depend (do inter (write ", ")@@ -841,8 +849,7 @@ (write " where"))))) unless (null (fromMaybe [] decls)) (do newline- indentSpaces <- getIndentSpaces- indented indentSpaces (lined (map pretty (fromMaybe [] decls))))+ indentedBlock (lined (map pretty (fromMaybe [] decls)))) decl (TypeDecl _ typehead typ) = depend (write "type ") (depend (pretty typehead)@@ -894,7 +901,13 @@ prettyInternal (Deriving _ heads) = do write "deriving" space- parens (commas (map pretty heads))+ let heads' =+ if length heads == 1+ then map stripParens heads+ else heads+ parens (commas (map pretty heads'))+ where stripParens (IParen _ iRule) = stripParens iRule+ stripParens x = x instance Pretty Alt where prettyInternal x =@@ -906,10 +919,8 @@ Nothing -> return () Just binds -> do newline- indentSpaces <- getIndentSpaces- indented indentSpaces- (depend (write "where ")- (pretty binds))+ indentedBlock (depend (write "where ")+ (pretty binds)) instance Pretty Asst where prettyInternal x =@@ -934,8 +945,14 @@ prettyInternal x = case x of BangedTy _ -> write "!"- UnpackedTy _ -> write "{-# UNPACK #-} !"+ LazyTy _ -> write "~"+ NoStrictAnnot _ -> pure () +instance Pretty Unpackedness where+ prettyInternal (Unpack _) = write "{-# UNPACK -#}"+ prettyInternal (NoUnpack _) = write "{-# NOUNPACK -#}"+ prettyInternal (NoUnpackPragma _) = pure ()+ instance Pretty Binds where prettyInternal x = case x of@@ -955,15 +972,12 @@ Just kind -> do write " :: " pretty kind)))- ClsTyFam _ h mkind ->+ ClsTyFam _ h mkind minj -> depend (write "type ") (depend (pretty h)- (case mkind of- Nothing -> return ()- Just kind ->- do write " :: "- pretty kind))- ClsTyDef _ this that ->+ (depend (traverse_ (\kind -> write " :: " >> pretty kind) mkind)+ (traverse_ pretty minj)))+ ClsTyDef _ (TypeEqn _ this that) -> do write "type " pretty this write " = "@@ -1021,6 +1035,9 @@ swing (write " " >> rhsSeparator >> write " ") (pretty e) +instance Pretty InjectivityInfo where+ prettyInternal x = pretty' x+ instance Pretty InstDecl where prettyInternal i = case i of@@ -1044,10 +1061,8 @@ Nothing -> return () Just binds -> do newline- indentSpaces <- getIndentSpaces- indented indentSpaces- (depend (write "where ")- (pretty binds))+ indentedBlock (depend (write "where ")+ (pretty binds)) InfixMatch _ pat1 name pats rhs mbinds -> do depend (do pretty pat1 space@@ -1062,10 +1077,8 @@ Nothing -> return () Just binds -> do newline- indentSpaces <- getIndentSpaces- indented indentSpaces- (depend (write "where ")- (pretty binds))+ indentedBlock (depend (write "where ")+ (pretty binds)) instance Pretty PatField where prettyInternal x =@@ -1245,6 +1258,10 @@ instance Pretty Kind where prettyInternal = pretty' +instance Pretty ResultSig where+ prettyInternal (KindSig _ kind) = pretty kind+ prettyInternal (TyVarSig _ tyVarBind) = pretty tyVarBind+ instance Pretty Literal where prettyInternal (String _ _ rep) = do write "\""@@ -1313,7 +1330,10 @@ prettyInternal = pretty' instance Pretty WarningText where- prettyInternal = pretty'+ prettyInternal (DeprText _ s) =+ write "{-# DEPRECATED " >> string s >> write " #-}"+ prettyInternal (WarnText _ s) =+ write "{-# WARNING " >> string s >> write " #-}" instance Pretty ExportSpecList where prettyInternal (ExportSpecList _ es) =
− src/HIndent/Styles/ChrisDone.hs
@@ -1,528 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}---- | Chris Done's style.------ Documented here: <https://github.com/chrisdone/haskell-style-guide>--module HIndent.Styles.ChrisDone where--import HIndent.Pretty-import HIndent.Comments-import HIndent.Types--import Control.Monad-import Control.Monad.Loops-import Control.Monad.State.Class-import Data.Int-import Data.Maybe-import Language.Haskell.Exts.Annotated (parseExpWithComments)-import Language.Haskell.Exts.Annotated.Fixity-import Language.Haskell.Exts.Annotated.Syntax-import Language.Haskell.Exts.Parser (ParseResult(..))-import Prelude hiding (exp)-import Data.Monoid------------------------------------------------------------------------------------- Style configuration---- | A short function name.-shortName :: Int64-shortName = 10---- | Column limit: 50-smallColumnLimit :: Int64-smallColumnLimit = 50---- | Empty state.-data State =- State---- | The printer style.-chrisDone :: Style-chrisDone =- Style {styleName = "chris-done"- ,styleAuthor = "Chris Done"- ,styleDescription = "Chris Done's personal style. Documented here: <https://github.com/chrisdone/haskell-style-guide>"- ,styleInitialState = State- ,styleExtenders =- [Extender exp- ,Extender fieldupdate- ,Extender rhs- ,Extender contextualGuardedRhs- ,Extender stmt- ,Extender decl- ,Extender types]- ,styleDefConfig =- defaultConfig {configMaxColumns = 80- ,configIndentSpaces = 2}- ,styleCommentPreprocessor = return}------------------------------------------------------------------------------------- Extenders--types :: Type NodeInfo -> Printer s ()-types (TyTuple _ boxed tys) =- depend (write (case boxed of- Unboxed -> "(#"- Boxed -> "("))- (do (fits,_) <- fitsOnOneLine p- if fits- then p- else prefixedLined ","- (map pretty tys)- write (case boxed of- Unboxed -> "#)"- Boxed -> ")"))- where p = commas (map pretty tys)-types e = prettyNoExt e---- | Pretty print type signatures like------ foo :: (Show x,Read x)--- => (Foo -> Bar)--- -> Maybe Int--- -> (Char -> X -> Y)--- -> IO ()----decl :: Decl NodeInfo -> Printer s ()-decl (TypeDecl _ head ty) =- do write "type "- pretty head- write " = "- (fits,st) <- fitsOnOneLine (pretty ty)- if fits- then put st- else do newline- indented 2 (pretty ty)-decl (TypeSig _ names ty') =- do (fitting,st) <- isSmallFitting dependent- if fitting- then put st- else do inter (write ", ")- (map pretty names)- newline- indentSpaces <- getIndentSpaces- indented indentSpaces- (depend (write ":: ")- (declTy ty'))- where dependent =- depend (do inter (write ", ")- (map pretty names)- write " :: ")- (declTy ty')- declTy dty =- case dty of- TyForall _ mbinds mctx ty ->- do case mbinds of- Nothing -> return ()- Just ts ->- do write "forall "- spaced (map pretty ts)- write ". "- newline- case mctx of- Nothing -> prettyTy ty- Just ctx ->- do pretty ctx- newline- indented (-3)- (depend (write "=> ")- (prettyTy ty))- _ -> prettyTy dty- collapseFaps (TyFun _ arg result) = arg : collapseFaps result- collapseFaps e = [e]- prettyTy ty =- do (fits,st) <- fitsOnOneLine (pretty ty)- if fits- then put st- else case collapseFaps ty of- [] -> pretty ty- tys ->- prefixedLined "-> "- (map pretty tys)-decl e = prettyNoExt e---- | I want field updates to be dependent or newline.-fieldupdate :: FieldUpdate NodeInfo -> Printer t ()-fieldupdate e =- case e of- FieldUpdate _ n e' ->- dependOrNewline- (do pretty n- write " = ")- e'- pretty- _ -> prettyNoExt e---- | Right-hand sides are dependent.-rhs :: Rhs NodeInfo -> Printer t ()-rhs grhs =- do inCase <- gets psInsideCase- if inCase- then unguardedalt grhs- else unguardedrhs grhs---- | Right-hand sides are dependent.-unguardedrhs :: Rhs NodeInfo -> Printer t ()-unguardedrhs (UnGuardedRhs _ e) =- do indentSpaces <- getIndentSpaces- indented indentSpaces- (dependOrNewline (write " = ")- e- pretty)-unguardedrhs e = prettyNoExt e---- | Unguarded case alts.-unguardedalt :: Rhs NodeInfo -> Printer t ()-unguardedalt (UnGuardedRhs _ e) =- dependOrNewline- (write " -> ")- e- (indented 2 .- pretty)-unguardedalt e = prettyNoExt e---- | Decide whether to do alts or rhs based on the context.-contextualGuardedRhs :: GuardedRhs NodeInfo -> Printer t ()-contextualGuardedRhs grhs =- do inCase <- gets psInsideCase- if inCase- then guardedalt grhs- else guardedrhs grhs---- | I want guarded RHS be dependent or newline.-guardedrhs :: GuardedRhs NodeInfo -> Printer t ()-guardedrhs (GuardedRhs _ stmts e) =- indented 1- (do prefixedLined- ","- (map (\p ->- do space- pretty p)- stmts)- dependOrNewline- (write " = ")- e- (indented 1 .- pretty))---- | I want guarded alts be dependent or newline.-guardedalt :: GuardedRhs NodeInfo -> Printer t ()-guardedalt (GuardedRhs _ stmts e) =- indented 1- (do (prefixedLined- ","- (map (\p ->- do space- pretty p)- stmts))- dependOrNewline- (write " -> ")- e- (indented 1 .- pretty))---- Do statements need to handle infix expression indentation specially because--- do x *--- y--- is two invalid statements, not one valid infix op.-stmt :: Stmt NodeInfo -> Printer t ()-stmt (Qualifier _ e@(InfixApp _ a op b)) =- do col <- fmap (psColumn . snd)- (sandbox (write ""))- infixApp e a op b (Just col)-stmt (Generator _ p e) =- do indentSpaces <- getIndentSpaces- pretty p- indented indentSpaces- (dependOrNewline- (write " <- ")- e- pretty)-stmt e = prettyNoExt e---- | Expressions-exp :: Exp NodeInfo -> Printer t ()-exp e@(QuasiQuote _ "i" s) =- do parseMode <- gets psParseMode- case parseExpWithComments parseMode s of- ParseOk (e',comments) ->- do depend (do write "["- string "i"- write "|")- (do exp (snd (annotateComments (fromMaybe e' (applyFixities baseFixities e'))- comments))- write "|]")- _ -> prettyNoExt e--- Infix applications will render on one line if possible, otherwise--- if any of the arguments are not "flat" then that expression is--- line-separated.-exp e@(InfixApp _ a op b) =- infixApp e a op b Nothing--- | We try to render everything on a flat line. More than one of the--- arguments are not flat and it wouldn't be a single liner.--- If the head is short we depend, otherwise we swing.-exp (App _ op a) =- do orig <- gets psIndentLevel- dependBind- (do (short,st) <- isShort f- put st- space- return short)- (\headIsShort ->- do let flats = map isFlat args- flatish =- length (filter not flats) <- 2- if (headIsShort && flatish) ||- all id flats- then do ((singleLiner,overflow),st) <- sandboxNonOverflowing args- if singleLiner && not overflow- then put st- else multi orig args headIsShort- else multi orig args headIsShort)- where (f,args) = flatten op [a]- flatten :: Exp NodeInfo- -> [Exp NodeInfo]- -> (Exp NodeInfo,[Exp NodeInfo])- flatten (App _ f' a') b =- flatten f' (a' : b)- flatten f' as = (f',as)--- | Lambdas are dependent if they can be.-exp (Lambda _ ps b) =- depend (write "\\" >> maybeSpace)- (do spaced (map pretty ps)- dependOrNewline- (write " -> ")- b- (indented 1 .- pretty))- where maybeSpace = case ps of- (PBangPat {}):_ -> space- (PIrrPat {}):_ -> space- _ -> return ()-exp (Tuple _ boxed exps) =- depend (write (case boxed of- Unboxed -> "(#"- Boxed -> "("))- (do (fits,_) <- fitsOnOneLine p- if fits- then p- else prefixedLined ","- (map pretty exps)- write (case boxed of- Unboxed -> "#)"- Boxed -> ")"))- where p = commas (map pretty exps)-exp (List _ es) =- do (ok,st) <- sandbox renderFlat- if ok- then put st- else brackets (prefixedLined ","- (map pretty es))- where renderFlat =- do line <- gets psLine- brackets (commas (map pretty es))- st <- get- columnLimit <- getColumnLimit- let overflow = psColumn st > columnLimit- single = psLine st == line- return (not overflow && single)-exp (ListComp _ e qstmt) =- brackets (do pretty e- unless (null qstmt) (do (ok,st) <- sandbox oneLiner- if ok- then put st- else lined))- where oneLiner = do line <- gets psLine- write "|"- commas (map pretty qstmt)- st <- get- columnLimit <- getColumnLimit- let overflow = psColumn st > columnLimit- single = psLine st == line- return (not overflow && single)- lined =- do newline- indented (-1)- (write "|")- prefixedLined- ","- (map pretty qstmt)-exp e = prettyNoExt e------------------------------------------------------------------------------------- Indentation helpers---- | Sandbox and render the nodes on multiple lines, returning whether--- each is a single line.-sandboxSingles :: Pretty ast- => [ast NodeInfo] -> Printer t (Bool,PrintState t)-sandboxSingles args =- sandbox (allM (\(i,arg) ->- do when (i /=- (0 :: Int))- newline- line <- gets psLine- pretty arg- st <- get- return (psLine st == line))- (zip [0 ..] args))---- | Render multi-line nodes.-multi :: Pretty ast- => Int64 -> [ast NodeInfo] -> Bool -> Printer t ()-multi orig args headIsShort =- if headIsShort- then lined (map pretty args)- else do (allAreSingle,st) <- sandboxSingles args- if allAreSingle- then put st- else do newline- indentSpaces <- getIndentSpaces- column (orig + indentSpaces)- (lined (map pretty args))---- | Sandbox and render the node on a single line, return whether it's--- on a single line and whether it's overflowing.-sandboxNonOverflowing :: Pretty ast- => [ast NodeInfo] -> Printer t ((Bool,Bool),PrintState t)-sandboxNonOverflowing args =- sandbox (do line <- gets psLine- columnLimit <- getColumnLimit- singleLineRender- st <- get- return (psLine st == line,psColumn st > columnLimit + 20))- where singleLineRender =- spaced (map pretty args)------------------------------------------------------------------------------------- Predicates---- | Is the expression "short"? Used for app heads.-isShort :: (Pretty ast)- => ast NodeInfo -> Printer t (Bool,PrintState t)-isShort p =- do line <- gets psLine- orig <- fmap (psColumn . snd)- (sandbox (write ""))- (_,st) <- sandbox (pretty p)- return (psLine st == line &&- (psColumn st < orig + shortName)- ,st)---- | Is the given expression "small"? I.e. does it fit on one line and--- under 'smallColumnLimit' columns.-isSmall :: MonadState (PrintState t) m- => m a -> m (Bool,PrintState t)-isSmall p =- do line <- gets psLine- (_,st) <- sandbox p- return (psLine st == line && psColumn st < smallColumnLimit,st)---- | Is the given expression "small"? I.e. does it fit under--- 'smallColumnLimit' columns.-isSmallFitting :: MonadState (PrintState t) m- => m a -> m (Bool,PrintState t)-isSmallFitting p =- do (_,st) <- sandbox p- return (psColumn st < smallColumnLimit,st)---- | Is an expression flat?-isFlat :: Exp NodeInfo -> Bool-isFlat (Lambda _ _ e) = isFlat e-isFlat (App _ a b) = isName a && isName b- where isName (Var{}) = True- isName _ = False-isFlat (InfixApp _ a _ b) = isFlat a && isFlat b-isFlat (NegApp _ a) = isFlat a-isFlat VarQuote{} = True-isFlat TypQuote{} = True-isFlat (List _ []) = True-isFlat Var{} = True-isFlat Lit{} = True-isFlat Con{} = True-isFlat (LeftSection _ e _) = isFlat e-isFlat (RightSection _ _ e) = isFlat e-isFlat _ = False---- | Does printing the given thing overflow column limit? (e.g. 80)-fitsOnOneLine :: MonadState (PrintState s) m => m a -> m (Bool,PrintState s)-fitsOnOneLine p =- do line <- gets psLine- (_,st) <- sandbox p- columnLimit <- getColumnLimit- return (psLine st == line && psColumn st < columnLimit,st)---- | Does printing the given thing overflow column limit? (e.g. 80)-fitsInColumnLimit :: Printer t a -> Printer t (Bool,PrintState t)-fitsInColumnLimit p =- do (_,st) <- sandbox p- columnLimit <- getColumnLimit- return (psColumn st < columnLimit,st)------------------------------------------------------------------------------------- Helpers--infixApp :: Exp NodeInfo- -> Exp NodeInfo- -> QOp NodeInfo- -> Exp NodeInfo- -> Maybe Int64- -> Printer s ()-infixApp e a op b indent =- do (fits,st) <-- fitsOnOneLine- (spaced (map (\link ->- case link of- OpChainExp e' -> pretty e'- OpChainLink qop -> pretty qop)- (flattenOpChain e)))- if fits- then put st- else do prettyWithIndent a- space- pretty op- newline- case indent of- Nothing -> prettyWithIndent b- Just col ->- do indentSpaces <- getIndentSpaces- column (col + indentSpaces)- (prettyWithIndent b)- where prettyWithIndent e' =- case e' of- (InfixApp _ a' op' b') ->- infixApp e' a' op' b' indent- _ -> pretty e'---- | A link in a chain of operator applications.-data OpChainLink l- = OpChainExp (Exp l)- | OpChainLink (QOp l)- deriving (Show)---- | Flatten a tree of InfixApp expressions into a chain of operator--- links.-flattenOpChain :: Exp l -> [OpChainLink l]-flattenOpChain (InfixApp _ left op right) =- flattenOpChain left <>- [OpChainLink op] <>- flattenOpChain right-flattenOpChain e = [OpChainExp e]---- | Make the right hand side dependent if it's flat, otherwise--- newline it.-dependOrNewline- :: Printer t ()- -> Exp NodeInfo- -> (Exp NodeInfo -> Printer t ())- -> Printer t ()-dependOrNewline left right f =- do (fits,st) <- fitsOnOneLine (depend left (f right))- if fits- then put st- else do left- newline- (f right)
− src/HIndent/Styles/Cramer.hs
@@ -1,908 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE FlexibleContexts #-}---- | Enno Cramer's Style.--module HIndent.Styles.Cramer (cramer) where--import Control.Monad (forM_, replicateM_, unless, when)-import Control.Monad.State.Strict (MonadState, get, gets, put)--import Data.List (intersperse, sortOn)-import Data.Maybe (catMaybes, isJust, mapMaybe)--import Language.Haskell.Exts.Annotated.Syntax-import Language.Haskell.Exts.Comments-import Language.Haskell.Exts.SrcLoc-import Language.Haskell.Exts (prettyPrint)--import HIndent.Pretty hiding (inter, spaced)-import HIndent.Types---- | Line breaking mode for syntactical constructs.-data LineBreak- = Free -- ^ Break whenever- | Single -- ^ Force single line (if possible)- | Multi -- ^ Force multiple lines- deriving (Eq,Enum,Show)---- | Printer state.-data State =- State {cramerLineBreak :: LineBreak -- ^ Current line breaking mode- ,cramerLangPragmaLength :: Int -- ^ Padding length for pragmas- ,cramerModuleImportLength :: Int -- ^ Padding length for module imports- ,cramerRecordFieldLength :: Int -- ^ Padding length for record fields- }- deriving (Show)---- | Syntax shortcut for Extenders.-type Extend f = f NodeInfo -> Printer State ()---- | Style definition.-cramer :: Style-cramer =- Style {styleName = "cramer"- ,styleAuthor = "Enno Cramer"- ,styleDescription = "Enno Cramer's style"- ,styleInitialState =- State {cramerLineBreak = Free- ,cramerLangPragmaLength = 0- ,cramerModuleImportLength = 0- ,cramerRecordFieldLength = 0}- ,styleExtenders =- [Extender extModule- ,Extender extModulePragma- ,Extender extModuleHead- ,Extender extExportSpecList- ,Extender extImportDecl- ,Extender extDecl- ,Extender extDeclHead- ,Extender extConDecl- ,Extender extFieldDecl- ,Extender extDeriving- ,Extender extRhs- ,Extender extContext- ,Extender extType- ,Extender extPat- ,Extender extExp- ,Extender extStmt- ,Extender extMatch- ,Extender extBinds- ,Extender extFieldUpdate]- ,styleDefConfig =- defaultConfig {configMaxColumns = 80- ,configIndentSpaces = 4- ,configClearEmptyLines = True}- ,styleCommentPreprocessor = return}------------------------------------------------------------------------------------- Helper---- | Return an ast node's SrcSpan.-nodeSrcSpan :: Annotated a => a NodeInfo -> SrcSpan-nodeSrcSpan = srcInfoSpan . nodeInfoSpan . ann---- | Turn a Name into a String-nameStr :: Name a -> String-nameStr (Ident _ s) = s-nameStr (Symbol _ s) = "(" ++ s ++ ")"---- | The difference between current column and indent level to force a--- line break in reduceIndent.-maxDependOverhead :: Integral a => a-maxDependOverhead = 20---- | Extract the name as a String from a ModuleName-moduleName :: ModuleName a -> String-moduleName (ModuleName _ s) = s---- | Extract the names of a ModulePragma-pragmaNames :: ModulePragma a -> [String]-pragmaNames (LanguagePragma _ names) = map nameStr names-pragmaNames _ = []---- | Return whether a data type has only empty constructors.-isEnum :: Decl NodeInfo -> Bool-isEnum (DataDecl _ (DataType _) Nothing (DHead _ _) constructors _) =- all isSimple constructors- where isSimple (QualConDecl _ Nothing Nothing (ConDecl _ _ [])) = True- isSimple _ = False-isEnum _ = False---- | Return whether a data type has only zero or one constructor.-isSingletonType :: Decl NodeInfo -> Bool-isSingletonType (DataDecl _ _ _ _ [] _) = True-isSingletonType (DataDecl _ _ _ _ [ _ ] _) = True-isSingletonType _ = False---- | If the given String is smaller than the given length, pad on--- right with spaces until the length matches.-padRight :: Int -> String -> String-padRight l s = take (max l (length s)) (s ++ repeat ' ')---- | Return comments with matching location.-filterComments :: Annotated a => (Maybe ComInfoLocation -> Bool) -> a NodeInfo -> [ComInfo]-filterComments f = filter (f . comInfoLocation) . nodeInfoComments . ann---- | Return whether an AST node has matching comments.-hasComments :: Annotated a => (Maybe ComInfoLocation -> Bool) -> a NodeInfo -> Bool-hasComments f = not . null . filterComments f---- | Copy comments marked After from one AST node to another.-copyComments :: (Annotated ast1,Annotated ast2)- => ComInfoLocation- -> ast1 NodeInfo- -> ast2 NodeInfo- -> ast2 NodeInfo-copyComments loc from to = amap updateComments to- where updateComments info = info { nodeInfoComments = oldComments ++ newComments }- oldComments = filterComments (/= Just loc) to- newComments = filterComments (== Just loc) from---- | Return the number of line breaks between AST nodes.-lineDelta- :: (Annotated ast1,Annotated ast2)- => ast1 NodeInfo -> ast2 NodeInfo -> Int-lineDelta prev next = nextLine - prevLine- where prevLine = maximum (prevNodeLine : prevCommentLines)- nextLine = minimum (nextNodeLine : nextCommentLines)- prevNodeLine = srcSpanEndLine . nodeSrcSpan $ prev- nextNodeLine = srcSpanStartLine . nodeSrcSpan $ next- prevCommentLines =- map (srcSpanEndLine . commentSrcSpan) $- filterComments (== Just After) prev- nextCommentLines =- map (srcSpanStartLine . commentSrcSpan) $- filterComments (== Just Before) next- commentSrcSpan = annComment . comInfoComment- annComment (Comment _ sp _) = sp---- | Specialized forM_ for Maybe.-maybeM_ :: Monad m- => Maybe a -> (a -> m ()) -> m ()-maybeM_ = forM_---- | Simplified HIndent.Pretty.inter that does not modify the indent level.-inter :: MonadState (PrintState s) m- => m () -> [m ()] -> m ()-inter sep = sequence_ . intersperse sep---- | Simplified HIndent.Pretty.spaced that does not modify the indent level.-spaced :: MonadState (PrintState s) m- => [m ()] -> m ()-spaced = inter space---- | Indent one level.-indentFull :: MonadState (PrintState s) m- => m a -> m a-indentFull p = getIndentSpaces >>= flip indented p---- | Indent a half level.-indentHalf :: MonadState (PrintState s) m- => m a -> m a-indentHalf p = getIndentSpaces >>= flip indented p . (`div` 2)---- | Set indentation level to current column.-align :: MonadState (PrintState s) m- => m a -> m a-align p =- do st <- get- let col =- if psEolComment st- then psIndentLevel st- else max (psColumn st)- (psIndentLevel st)- column col p---- | Update the line breaking mode and restore afterwards.-withLineBreak- :: LineBreak -> Printer State a -> Printer State a-withLineBreak lb p =- do old <- gets (cramerLineBreak . psUserState)- modifyState $ \s -> s {cramerLineBreak = lb}- result <- p- modifyState $ \s -> s {cramerLineBreak = old}- return result---- | Use the first printer if it fits on a single line within the--- column limit, otherwise use the second.-attemptSingleLine- :: Printer State a -> Printer State a -> Printer State a-attemptSingleLine single multi =- do prevState <- get- case cramerLineBreak . psUserState $ prevState of- Single -> single- Multi -> multi- Free ->- do result <- withLineBreak Single single- col <- getColumn- row <- getLineNum- if row == psLine prevState &&- col <= configMaxColumns (psConfig prevState)- then return result- else do put prevState- multi---- | Same as attemptSingleLine, but execute the second printer in Multi--- mode. Used in type signatures to force either a single line or--- have each `->` on a line by itself.-attemptSingleLineType- :: Printer State a -> Printer State a -> Printer State a-attemptSingleLineType single multi =- attemptSingleLine single- (withLineBreak Multi multi)---- | Format a list-like structure on a single line.-listSingleLine :: Pretty a- => String- -> String- -> String- -> [a NodeInfo]- -> Printer State ()-listSingleLine open close _ [] =- do string open- space- string close-listSingleLine open close sep xs =- do string open- space- inter (string sep >> space) $ map pretty xs- space- string close---- | Format a list-like structure with each element on a line by--- itself.-listMultiLine- :: Pretty a- => String -> String -> String -> [a NodeInfo] -> Printer State ()-listMultiLine open close _ [] =- align $- do string open- newline- string close-listMultiLine open close sep xs =- align $- do string open- space- inter (newline >> string sep >> space) $ map pretty xs- newline- string close---- | Format a list-like structure on a single line, if possible, or--- each element on a line by itself.-listAttemptSingleLine :: Pretty a- => String- -> String- -> String- -> [a NodeInfo]- -> Printer State ()-listAttemptSingleLine open close sep xs =- attemptSingleLine (listSingleLine open close sep xs)- (listMultiLine open close sep xs)---- | Format a list-like structure, automatically breaking lines when--- the next separator and item do not fit within the column limit.-listAutoWrap- :: Pretty a- => String -> String -> String -> [a NodeInfo] -> Printer State ()-listAutoWrap open close sep ps =- align $- do string open- unless (null ps) $- do space- pretty $ head ps- forM_ (map (\p -> string sep >> space >> pretty p)- (tail ps)) $- \p ->- do fits <- fitsColumnLimit p- unless fits newline- p- space- string close- where fitsColumnLimit p =- fmap fst . sandbox $- do _ <- p- col <- getColumn- limit <- gets (configMaxColumns . psConfig)- return $ col < limit---- | Like `inter newline . map pretty`, but preserve empty lines--- between elements.-preserveLineSpacing- :: (Pretty ast,Annotated ast)- => [ast NodeInfo] -> Printer State ()-preserveLineSpacing [] = return ()-preserveLineSpacing asts@(first:rest) =- do pretty first- forM_ (zip asts rest) $- \(prev,cur) ->- do replicateM_ (max 1 $ lineDelta prev cur)- newline- pretty cur---- | `reduceIndent short long printer` produces either `short printer`--- or `newline >> indentFull (long printer)`, depending on whether the--- current column is sufficiently near to the current indentation depth.------ The function is used to avoid overly big dependent indentation by--- heuristically breaking and non-dependently indenting.-reduceIndent :: (Printer State () -> Printer State ())- -> (Printer State () -> Printer State ())- -> Printer State ()- -> Printer State ()-reduceIndent short long printer =- do linebreak <- gets (cramerLineBreak . psUserState)- case linebreak of- Single -> single- Multi -> multi- Free ->- do curCol <- getColumn- curIndent <- gets psIndentLevel- indentSpaces <- gets (configIndentSpaces . psConfig)- if (curCol - curIndent - indentSpaces) < maxDependOverhead- then single- else multi- where single = short printer- multi = newline >> indentFull (long printer)---- | Either simply precede the given printer with a space, or with--- indent the the printer after a newline, depending on the available--- space.-spaceOrIndent :: Printer State () -> Printer State ()-spaceOrIndent = reduceIndent (\p -> space >> p) id---- | Special casing for `do` blocks and leading comments-inlineExpr :: (Printer State () -> Printer State ()) -> Exp NodeInfo -> Printer State ()-inlineExpr _ expr- | not (null (filterComments (== (Just Before)) expr)) =- do newline- indentFull $ pretty expr-inlineExpr _ expr@Do{} =- do space- pretty expr-inlineExpr fmt expr = fmt (pretty expr)------------------------------------------------------------------------------------- Printer for reused syntactical constructs--whereBinds :: Binds NodeInfo -> Printer State ()-whereBinds binds =- do newline- indentHalf $- do write "where"- newline- indentHalf $ pretty binds--rhsExpr :: Exp NodeInfo -> Printer State ()-rhsExpr expr =- do space- rhsSeparator- inlineExpr spaceOrIndent expr--guardedRhsExpr- :: GuardedRhs NodeInfo -> Printer State ()-guardedRhsExpr (GuardedRhs _ guards expr) =- depend (write "| ") $- do inter (write ", ") $ map pretty guards- rhsExpr expr---- | Pretty print a name for being an infix operator.-prettyInfixOp :: MonadState (PrintState s) m- => QName NodeInfo -> m ()-prettyInfixOp op =- case op of- Qual{} ->- do write "`"- pretty' op- write "`"- UnQual _ n ->- case n of- Ident _ i -> string ("`" ++ i ++ "`")- Symbol _ s -> string s- Special _ s -> pretty s--tupleExpr- :: Pretty ast- => Boxed -> [ast NodeInfo] -> Printer State ()-tupleExpr boxed exprs = attemptSingleLine single multi- where single =- do string open- inter (write ", ") $ map pretty exprs- string close- multi = listMultiLine open close "," exprs- (open,close) =- case boxed of- Unboxed -> ("(#","#)")- Boxed -> ("(",")")--listExpr :: Pretty ast- => [ast NodeInfo] -> Printer State ()-listExpr [] = write "[]"-listExpr xs = listAttemptSingleLine "[" "]" "," xs--recordExpr- :: (Pretty ast,Pretty ast')- => ast NodeInfo -> [ast' NodeInfo] -> Printer State ()-recordExpr expr updates =- do pretty expr- space- listAttemptSingleLine "{" "}" "," updates--ifExpr :: (Printer State () -> Printer State ())- -> Exp NodeInfo- -> Exp NodeInfo- -> Exp NodeInfo- -> Printer State ()-ifExpr indent cond true false = attemptSingleLine single multi- where single = spaced [if',then',else']- multi =- align $- do if'- indent $- do newline- then'- newline- else'- if' = write "if " >> pretty cond- then' = write "then " >> pretty true- else' = write "else " >> pretty false--letExpr :: Binds NodeInfo -> Exp NodeInfo -> Printer State ()-letExpr binds expr =- align $- do depend (write "let ") $ pretty binds- newline- write "in"- inlineExpr (\p -> newline >> indentFull p) expr--infixExpr :: Exp NodeInfo -> Printer State ()--- No line break before do-infixExpr (InfixApp _ arg1 op arg2@Do{}) =- spaced [pretty arg1,pretty op,pretty arg2]--- Try to preserve existing line break before and after infix ops-infixExpr (InfixApp _ arg1 op arg2)- | deltaBefore /= 0 && deltaAfter /= 0 =- align $ inter newline [pretty arg1,pretty op,pretty arg2]- | deltaBefore /= 0 || deltaAfter /= 0 =- pretty arg1 >>- preserveLinebreak- deltaBefore- (pretty op >>- preserveLinebreak deltaAfter- (pretty arg2))- | otherwise = attemptSingleLine single multi- where single = spaced [pretty arg1,pretty op,pretty arg2]- multi =- do pretty arg1- space- pretty op- newline- indentFull $ pretty arg2- preserveLinebreak delta p =- if delta > 0- then newline >> indentFull p- else space >> p- deltaBefore = lineDelta arg1 op- deltaAfter = lineDelta op arg2-infixExpr _ = error "not an InfixApp"--applicativeExpr :: Exp NodeInfo- -> [(QOp NodeInfo,Exp NodeInfo)]- -> Printer State ()-applicativeExpr ctor args = attemptSingleLine single multi- where single = spaced (pretty ctor : map prettyArg args)- multi =- do pretty ctor- depend space $ inter newline $ map prettyArg args- prettyArg (op,arg) = pretty op >> space >> pretty arg--typeSig :: Type NodeInfo -> Printer State ()-typeSig ty =- attemptSingleLineType (write ":: " >> pretty ty)- (align $ write ":: " >> pretty ty)--typeInfixExpr- :: Type NodeInfo -> Printer State ()--- As HIndent does not know about operator precedence, preserve--- existing line breaks, but do not add new ones.-typeInfixExpr (TyInfix _ arg1 op arg2)- | deltaBefore /= 0 && deltaAfter /= 0 =- align $ inter newline [pretty arg1,prettyInfixOp op,pretty arg2]- | deltaBefore /= 0 || deltaAfter /= 0 =- pretty arg1 >>- preserveLinebreak- deltaBefore- (prettyInfixOp op >>- preserveLinebreak deltaAfter- (pretty arg2))- | otherwise = spaced [pretty arg1,prettyInfixOp op,pretty arg2]- where preserveLinebreak delta p =- if delta > 0- then newline >> indentFull p- else space >> p- deltaBefore = lineDelta arg1 op- deltaAfter = lineDelta op arg2-typeInfixExpr _ = error "not a TyInfix"------------------------------------------------------------------------------------- Extenders--extModule :: Extend Module-extModule (Module _ mhead pragmas imports decls) =- do modifyState $ \s -> s {cramerLangPragmaLength = pragLen- ,cramerModuleImportLength = modLen}- inter (newline >> newline) $- catMaybes [unless' (null pragmas) $ preserveLineSpacing pragmas- ,pretty <$> mhead- ,unless' (null imports) $ preserveLineSpacing imports- ,unless' (null decls) $- do forM_ (init decls) $- \decl ->- do pretty decl- newline- unless (skipNewline decl) newline- pretty (last decls)]- where pragLen = maximum $ map length $ concatMap pragmaNames pragmas- modLen = maximum $ map (length . moduleName . importModule) imports- unless' cond expr =- if not cond- then Just expr- else Nothing- skipNewline TypeSig{} = True- skipNewline _ = False-extModule other = prettyNoExt other---- Align closing braces of pragmas-extModulePragma :: Extend ModulePragma-extModulePragma (LanguagePragma _ names) =- do namelen <- gets (cramerLangPragmaLength . psUserState)- forM_ names $- \name ->- do write "{-# LANGUAGE "- string $ padRight namelen $ nameStr name- write " #-}"--- Avoid increasing whitespace after OPTIONS string-extModulePragma (OptionsPragma _ mtool opt) =- do write "{-# OPTIONS"- maybeM_ mtool $ \tool -> do write "_"- string $ prettyPrint tool- space- string $ trim opt- write " #-}"- where trim = reverse . dropWhile (== ' ') . reverse . dropWhile (== ' ')-extModulePragma other = prettyNoExt other---- Empty or single item export list on one line, otherwise one item--- per line with parens and comma aligned-extModuleHead :: Extend ModuleHead-extModuleHead (ModuleHead _ name mwarn mexports) =- do mapM_ pretty mwarn- write "module "- pretty name- maybeM_ mexports $ \exports -> pretty exports- write " where"---- Align export list, one item per line-extExportSpecList :: Extend ExportSpecList-extExportSpecList (ExportSpecList _ exports) =- case exports of- [] -> write " ( )"- [e]- | not (hasComments (const True) e) -> write " ( " >> pretty e >> write " )"- (first:rest) ->- do newline- indentFull $- do write "( "- commentCol <- getColumn- align $ prettyExportSpec "" commentCol first- forM_ rest $- \export ->- do newline- prettyExportSpec ", " commentCol export- newline- write ")"- where printCommentsSimple loc ast =- let rawComments = filterComments (== Just loc) ast- in do preprocessor <- gets psCommentPreprocessor- comments <- preprocessor $ map comInfoComment rawComments- forM_ comments $- printComment (Just $ nodeSrcSpan ast)- prettyExportSpec prefix col spec =- do column col $ printCommentsSimple Before spec- string prefix- prettyNoExt spec- printCommentsSimple After spec---- Align import statements-extImportDecl :: Extend ImportDecl-extImportDecl ImportDecl{..} =- do if importQualified- then write "import qualified "- else write "import "- namelen <- gets (cramerModuleImportLength . psUserState)- if isJust importAs || isJust importSpecs- then string $ padRight namelen $ moduleName importModule- else string $ moduleName importModule- maybeM_ importAs $- \name ->- do write " as "- pretty name- maybeM_ importSpecs $- \(ImportSpecList _ importHiding specs) ->- do space- when importHiding $ write "hiding "- listAutoWrap "(" ")" "," $ sortOn prettyPrint specs--extDecl :: Extend Decl--- No dependent indentation for type decls-extDecl (TypeDecl _ declhead ty) =- do write "type "- pretty declhead- write " = "- indentFull $ pretty ty--- Fix whitespace before 'where' in class decl-extDecl (ClassDecl _ mcontext declhead fundeps mdecls) =- do depend (write "class ") $- withCtx mcontext $- depend (pretty declhead) $- depend (unless (null fundeps) $- write " | " >>- inter (write ", ")- (map pretty fundeps)) $- when (isJust mdecls) $ write " where"- maybeM_ mdecls $- \decls ->- do newline- indentFull $ preserveLineSpacing decls--- Align data constructors-extDecl decl@(DataDecl _ dataOrNew mcontext declHead constructors mderiv) =- do mapM_ pretty mcontext- pretty dataOrNew- space- pretty declHead- write " ="- if isEnum decl || isSingletonType decl- then attemptSingleLine single multi- else multi- maybeM_ mderiv $ \deriv -> indentFull $ newline >> pretty deriv- where single =- do space- inter (write " | ") $ map pretty constructors- multi =- reduceIndent- (depend space . indented (-2))- (\p -> write " " >> p)- (inter (newline >> write "| ") $ map pretty constructors)--- Type signature either on a single line or split at arrows, aligned with '::'-extDecl (TypeSig _ names ty) =- do inter (write ", ") $ map pretty names- space- typeSig ty--- Preserve empty lines between function matches-extDecl (FunBind _ matches) = preserveLineSpacing matches--- Half-indent for where clause, half-indent binds-extDecl (PatBind _ pat rhs mbinds) =- do pretty pat- withCaseContext False $ pretty rhs- maybeM_ mbinds whereBinds-extDecl other = prettyNoExt other---- Do not modify indent level-extDeclHead :: Extend DeclHead-extDeclHead (DHApp _ dhead var) =- do pretty dhead- space- pretty var-extDeclHead other = prettyNoExt other--extConDecl :: Extend ConDecl--- No extra space after empty constructor-extConDecl (ConDecl _ name []) = pretty name-extConDecl (ConDecl _ name tys) = attemptSingleLine single multi- where single = spaced $ pretty name : map pretty tys- multi = depend (pretty name >> space) $ lined $ map pretty tys--- Align record fields-extConDecl (RecDecl _ name fields) =- do modifyState $ \s -> s {cramerRecordFieldLength = fieldLen}- pretty name- space- case fields of- [] -> write "{ }"- [_] -> listAttemptSingleLine "{" "}" "," fields- _ -> listMultiLine "{" "}" "," fields- where fieldLen = maximum $ map (length . nameStr) fnames- fnames =- mapMaybe (\(FieldDecl _ ns _) ->- case ns of- [n] -> Just n- _ -> Nothing)- fields-extConDecl other = prettyNoExt other--extFieldDecl :: Extend FieldDecl-extFieldDecl (FieldDecl _ [name] ty) =- do namelen <- gets (cramerRecordFieldLength . psUserState)- string $ padRight namelen $ nameStr name- space- typeSig ty-extFieldDecl other = prettyNoExt other---- Derived instances separated by comma and space, no line breaking-extDeriving :: Extend Deriving-extDeriving (Deriving _ instHeads) =- do write "deriving "- case instHeads of- [x] -> pretty x- xs -> parens $ inter (write ", ") $ map pretty xs--extRhs :: Extend Rhs-extRhs (UnGuardedRhs _ expr) = rhsExpr expr-extRhs (GuardedRhss _ [rhs]) = space >> guardedRhsExpr rhs-extRhs (GuardedRhss _ rhss) =- forM_ rhss $- \rhs ->- do newline- indentFull $ guardedRhsExpr rhs---- Type constraints on a single line-extContext :: Extend Context-extContext (CxTuple _ ctxs) = parens $ inter (write ", ") $ map pretty ctxs-extContext other = prettyNoExt other--extType :: Extend Type-extType (TyForall _ mforall mcontext ty) = attemptSingleLine single multi- where single =- do maybeM_ mforall $ \vars -> prettyForall vars >> space- maybeM_ mcontext $ \context -> pretty context >> write " => "- pretty ty- multi =- do maybeM_ mforall $ \vars -> prettyForall vars >> newline- maybeM_ mcontext $- \context -> pretty context >> newline >> write "=> "- pretty ty- prettyForall vars =- do write "forall "- spaced $ map pretty vars- write "."--- Type signature should line break at each arrow if necessary-extType (TyFun _ from to) =- attemptSingleLineType (pretty from >> write " -> " >> pretty to)- (pretty from >> newline >> write "-> " >> pretty to)--- Parentheses reset forced line breaking-extType (TyParen _ ty) = withLineBreak Free $ parens $ pretty ty--- Tuple types on one line, with space after comma-extType (TyTuple _ boxed tys) = withLineBreak Free $ tupleExpr boxed tys--- Infix application-extType expr@TyInfix{} = typeInfixExpr expr-extType other = prettyNoExt other--extPat :: Extend Pat--- Infix application with space around operator-extPat (PInfixApp _ arg1 op arg2) =- do pretty arg1- space- prettyInfixOp op- space- pretty arg2--- Tuple patterns on one line, with space after comma-extPat (PTuple _ boxed pats) = withLineBreak Single $ tupleExpr boxed pats--- List patterns on one line, with space after comma-extPat (PList _ pats) = withLineBreak Single $ listExpr pats-extPat other = prettyNoExt other--extExp :: Extend Exp--- Function application on a single line or align arguments-extExp expr@(App _ fun arg) = attemptSingleLine single multi- where single = pretty fun >> space >> pretty arg- multi =- pretty fun' >> space >> align (lined $ map pretty $ reverse args')- (fun',args') = collectArgs expr- collectArgs- :: Exp NodeInfo -> (Exp NodeInfo,[Exp NodeInfo])- collectArgs app@(App _ g y) =- let (f,args) = collectArgs g- in (f,copyComments After app y : args)- collectArgs nonApp = (nonApp,[])--- Infix application on a single line or indented rhs-extExp expr@InfixApp{} =- if all (isApplicativeOp . fst) opArgs && isFmap (fst $ head opArgs)- then applicativeExpr firstArg opArgs- else infixExpr expr- where (firstArg,opArgs) = collectOpExps expr- collectOpExps- :: Exp NodeInfo -> (Exp NodeInfo,[(QOp NodeInfo,Exp NodeInfo)])- collectOpExps app@(InfixApp _ left op right) =- let (ctorLeft,argsLeft) = collectOpExps left- (ctorRight,argsRight) = collectOpExps right- in (ctorLeft,argsLeft ++ [(op,copyComments After app ctorRight)] ++ argsRight)- collectOpExps e = (e,[])- isApplicativeOp :: QOp NodeInfo -> Bool- isApplicativeOp (QVarOp _ (UnQual _ (Symbol _ s))) =- head s == '<' && last s == '>'- isApplicativeOp _ = False- isFmap :: QOp NodeInfo -> Bool- isFmap (QVarOp _ (UnQual _ (Symbol _ "<$>"))) = True- isFmap _ = False--- No space after lambda-extExp (Lambda _ pats expr) =- do write "\\"- maybeSpace- spaced $ map pretty pats- write " ->"- inlineExpr (\p -> attemptSingleLine (space >> p) (spaceOrIndent p)) expr- where maybeSpace =- case pats of- PBangPat{}:_ -> space- PIrrPat{}:_ -> space- _ -> return ()--- If-then-else on one line or newline and indent before then and else-extExp (If _ cond true false) = ifExpr id cond true false--- Newline before in-extExp (Let _ binds expr) = letExpr binds expr--- Tuples on a single line (no space inside parens but after comma) or--- one element per line with parens and comma aligned-extExp (Tuple _ boxed exprs) = tupleExpr boxed exprs--- List on a single line or one item per line with aligned brackets and comma-extExp (List _ exprs) = listExpr exprs--- Record construction and update on a single line or one line per--- field with aligned braces and comma-extExp (RecConstr _ qname updates) = recordExpr qname updates-extExp (RecUpdate _ expr updates) = recordExpr expr updates--- Full indentation for case alts and preserve empty lines between alts-extExp (Case _ expr alts) =- do write "case "- pretty expr- write " of"- newline- withCaseContext True $ indentFull $ preserveLineSpacing alts--- Line break and indent after do-extExp (Do _ stmts) =- do write "do"- newline- indentFull $ preserveLineSpacing stmts-extExp (ListComp _ e qstmt) =- brackets (do space- pretty e- unless (null qstmt)- (do newline- indented (-1)- (write "|")- prefixedLined ","- (map (\x -> do space- pretty x- space)- qstmt)))--- Type signatures like toplevel decl-extExp (ExpTypeSig _ expr ty) =- do pretty expr- space- typeSig ty-extExp other = prettyNoExt other--extStmt :: Extend Stmt-extStmt (Qualifier _ (If _ cond true false)) = ifExpr indentFull cond true false-extStmt other = prettyNoExt other--extMatch :: Extend Match--- Indent where same as for top level decl-extMatch (Match _ name pats rhs mbinds) =- do pretty name- space- spaced $ map pretty pats- withCaseContext False $ pretty rhs- maybeM_ mbinds whereBinds-extMatch other = prettyNoExt other---- Preserve empty lines between bindings-extBinds :: Extend Binds-extBinds (BDecls _ decls) = preserveLineSpacing decls-extBinds other = prettyNoExt other---- No line break after equal sign-extFieldUpdate :: Extend FieldUpdate-extFieldUpdate (FieldUpdate _ qname expr) =- do pretty qname- write " = "- pretty expr-extFieldUpdate other = prettyNoExt other
− src/HIndent/Styles/Fundamental.hs
@@ -1,23 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- | Fundamental built-in style. Defines no additional extensions or--- configurations beyond the default printer.--module HIndent.Styles.Fundamental where--import HIndent.Types----- | Empty state.-data State = State---- | The printer style.-fundamental :: Style-fundamental =- Style {styleName = "fundamental"- ,styleAuthor = "Chris Done"- ,styleDescription = "This style adds no extensions to the built-in printer."- ,styleInitialState = State- ,styleExtenders = []- ,styleDefConfig = defaultConfig- ,styleCommentPreprocessor = return}
− src/HIndent/Styles/Gibiansky.hs
@@ -1,1155 +0,0 @@-{-# LANGUAGE FlexibleContexts, OverloadedStrings, RecordWildCards, RankNTypes #-}-{-# OPTIONS_GHC -fno-warn-name-shadowing #-}--module HIndent.Styles.Gibiansky where--import Data.Foldable--- import Control.Applicative ((<$>))-import Data.Maybe-import Data.List (unfoldr, isPrefixOf)-import Control.Monad.Trans.Maybe-import Data.Functor.Identity-import Control.Monad.State.Strict hiding (state, State, forM_, sequence_)-import Data.Typeable--import HIndent.Pretty-import HIndent.Types--import Language.Haskell.Exts.Annotated.Syntax-import Language.Haskell.Exts.SrcLoc-import Language.Haskell.Exts.Pretty (prettyPrint)-import Language.Haskell.Exts.Comments-import Prelude hiding (exp, all, mapM_, minimum, and, maximum, concatMap, or, any, sequence_)---- | Empty state.-data State = State { gibianskyForceSingleLine :: Bool, gibianskyLetBind :: Bool }--userGets :: (State -> a) -> Printer State a-userGets f = gets (f . psUserState)--userModify :: (State -> State) -> Printer State ()-userModify f = modify (\s -> s { psUserState = f (psUserState s) })---- | The printer style.-gibiansky :: Style-gibiansky = Style { styleName = "gibiansky"- , styleAuthor = "Andrew Gibiansky"- , styleDescription = "Andrew Gibiansky's style"- , styleInitialState = State { gibianskyForceSingleLine = False, gibianskyLetBind = False }- , styleExtenders = [ Extender imp- , Extender modl- , Extender context- , Extender derivings- , Extender typ- , Extender exprs- , Extender rhss- , Extender guardedRhs- , Extender decls- , Extender stmts- , Extender condecls- , Extender alt- , Extender moduleHead- , Extender exportList- , Extender fieldUpdate- , Extender pragmas- , Extender pat- , Extender qualConDecl- ]- , styleDefConfig = defaultConfig { configMaxColumns = 100- , configIndentSpaces = indentSpaces- , configClearEmptyLines = True- }- , styleCommentPreprocessor = commentPreprocessor- }---- Field accessor for Comment.-commentContent :: Comment -> String-commentContent (Comment _ _ content) = content---- Field accessor for Comment.-commentSrcSpan :: Comment -> SrcSpan-commentSrcSpan (Comment _ srcSpan _) = srcSpan--commentPreprocessor :: MonadState (PrintState s) m => [Comment] -> m [Comment]-commentPreprocessor cs = do- config <- gets psConfig- col <- getColumn- return $ go (fromIntegral col) config cs-- where- go currentColumn config = concatMap mergeGroup . groupComments Nothing []- where- -- Group comments into blocks.- -- A comment block is the list of comments that are on consecutive lines,- -- and do not have an empty comment in between them. Empty comments are those with only whitespace.- -- Empty comments are in their own group.- groupComments :: Maybe Int -> [Comment] -> [Comment] -> [[Comment]]- groupComments nextLine accum (comment@(Comment multiline srcSpan str):comments)- | separateCommentCondition = useAsSeparateCommentGroup- | beginningOfUnprocessed str =- let (unprocessedLines, postUnprocessed) = span unprocessed comments- (endingLine, remLines) = case postUnprocessed of- x:xs -> ([x], xs)- [] -> ([], [])- separateCommentGroups = comment : unprocessedLines ++ endingLine- in currentGroupAsList ++ map (: []) separateCommentGroups ++ groupComments Nothing [] remLines- | isNothing nextLine || Just (srcSpanStartLine srcSpan) == nextLine = groupComments nextLine' (comment:accum) comments- | otherwise = currentGroupAsList ++ groupComments (Just $ srcSpanStartLine srcSpan + 1) [comment] comments- where- separateCommentCondition = or [multiline, isWhitespace str, " " `isPrefixOf` str, " >" `isPrefixOf` str]- useAsSeparateCommentGroup = currentGroupAsList ++ [comment] : groupComments nextLine' [] comments- nextCommentStartLine = srcSpanStartLine $ commentSrcSpan $ head comments- currentGroupAsList | null accum = []- | otherwise = [reverse accum]- nextLine' =- case nextLine of- Just x -> Just (x + 1)- Nothing -> Just nextCommentStartLine- groupComments _ [] [] = []- groupComments _ accum [] = [reverse accum]-- beginningOfUnprocessed :: String -> Bool- beginningOfUnprocessed str = any (`isPrefixOf` str) ["@", " @", " @"]-- unprocessed :: Comment -> Bool- unprocessed (Comment True _ _) = False- unprocessed (Comment _ _ str) = not $ beginningOfUnprocessed str-- isWhitespace :: String -> Bool- isWhitespace = all (\x -> x == ' ' || x == '\t')-- commentLen :: Int- commentLen = length ("--" :: String)-- -- Merge a group of comments into one comment.- mergeGroup :: [Comment] -> [Comment]- mergeGroup [] = error "Empty comment group"- mergeGroup comments@[Comment True _ _] = comments- mergeGroup comments =- let- firstSrcSpan = commentSrcSpan $ head comments- firstLine = srcSpanStartLine firstSrcSpan- firstCol = srcSpanStartColumn firstSrcSpan-- columnDelta = firstCol - currentColumn- maxStartColumn = maximum (map (srcSpanStartColumn . commentSrcSpan) comments)-- lineLen = fromIntegral (configMaxColumns config) - maxStartColumn - commentLen + columnDelta- content = breakCommentLines lineLen $ unlines (map commentContent comments)- srcSpanLines = map (firstLine +) [0 .. length content - 1]- srcSpans = map (\linum -> firstSrcSpan { srcSpanStartLine = linum, srcSpanEndLine = linum, srcSpanStartColumn = maxStartColumn }) srcSpanLines- in zipWith (Comment False) srcSpans content----- | Break a comment string into lines of a maximum character length.--- Each line starts with a space, mirroring the traditional way of writing comments:------ -- Hello--- -- Note the space after the '-'-breakCommentLines :: Int -> String -> [String]-breakCommentLines maxLen str- -- If there's no way to do this formatting, just give up- | any ((maxLen <) . length) (words str) = [str]-- -- If we already have a line of the appropriate length, leave it alone. This allows us to format- -- stuff ourselves in some cases.- | length (lines str) == 1 && length str <= maxLen = [dropTrailingNewlines str]-- | otherwise = unfoldr unfolder (words str)- where- -- Generate successive lines, consuming the words iteratively.- unfolder :: [String] -> Maybe (String, [String])- unfolder [] = Nothing- unfolder ws = Just $ go maxLen [] ws- where- go :: Int -- Characters remaining on the line to be used- -> [String] -- Accumulator: The words used so far on this line- -> [String] -- Unused words- -> (String, [String]) -- (Generated line, remaining words)- go remainingLen taken remainingWords =- case remainingWords of- -- If no more words remain, we're done- [] -> (generatedLine, [])- word:remWords ->- -- If the next word doesn't fit on this line, line break- let nextRemaining = remainingLen - length word - 1- in if nextRemaining < 0- then (generatedLine, remainingWords)- else go nextRemaining (word : taken) remWords- where- generatedLine = ' ' : unwords (reverse taken)--dropTrailingNewlines :: String -> String-dropTrailingNewlines = reverse . dropWhile (== '\n') . reverse---- | Number of spaces to indent by.-indentSpaces :: Integral a => a-indentSpaces = 2---- | Printer to indent one level.-indentOnce :: Printer s ()-indentOnce = replicateM_ indentSpaces space---- | How many exports to format in a single line.--- If an export list has more than this, it will be formatted as multiple lines.-maxSingleLineExports :: Integral a => a-maxSingleLineExports = 4--attemptSingleLine :: Printer State a -> Printer State a -> Printer State a-attemptSingleLine single multiple = do- prevState <- get- if gibianskyForceSingleLine $ psUserState prevState- then single- else do- -- Try printing on one line.- modifyState $ \st -> st { gibianskyForceSingleLine = True }- result <- single- modifyState $ \st -> st { gibianskyForceSingleLine = False }-- -- If it doesn't fit, reprint on multiple lines.- col <- getColumn- maxColumns <- configMaxColumns <$> gets psConfig- if col > maxColumns- then do- put prevState- multiple- else return result------------------------------------------------------------------------------------- Extenders-type Extend f = f NodeInfo -> Printer State ()---- | Format whole modules.-modl :: Extend Module-modl (Module _ mayModHead pragmas imps decls) = do- onSeparateLines pragmas- unless (null pragmas) $- unless (null imps && null decls && isNothing mayModHead) $- newline >> newline-- forM_ mayModHead $ \modHead -> do- pretty modHead- unless (null imps && null decls) (newline >> newline)-- onSeparateLines imps- unless (null imps || null decls) (newline >> newline)-- unless (null decls) $ do- forM_ (init decls) $ \decl -> do- pretty decl- newline- unless (skipFollowingNewline decl) newline- pretty (last decls)-modl m = prettyNoExt m--skipFollowingNewline :: Decl l -> Bool-skipFollowingNewline TypeSig{} = True-skipFollowingNewline InlineSig{} = True-skipFollowingNewline AnnPragma{} = True-skipFollowingNewline MinimalPragma{} = True-skipFollowingNewline _ = False---- | Format pragmas differently (language pragmas).-pragmas :: Extend ModulePragma-pragmas (LanguagePragma _ names) = do- write "{-# LANGUAGE "- inter (write ", ") $ map pretty names- write " #-}"-pragmas (OptionsPragma _ mtool opt) = do- write "{-# OPTIONS"- forM_ mtool $ \tool -> do- write "_"- string $ prettyPrint tool- write " "- string opt- write "#-}"-pragmas p = prettyNoExt p---- | Format patterns.-pat :: Extend Pat-pat (PTuple _ boxed pats) = writeTuple boxed pats-pat (PList _ pats) = singleLineList pats-pat (PRec _ name fields) = recUpdateExpr fields (pretty name) (map prettyCommentCallbacks fields)-pat p = prettyNoExt p---- | Format import statements.-imp :: Extend ImportDecl-imp ImportDecl{..} = do- write "import "- write $ if importQualified- then "qualified "- else " "- pretty importModule-- forM_ importAs $ \name -> do- write " as "- pretty name-- forM_ importSpecs $ \(ImportSpecList _ importHiding specs) -> do- space- when importHiding $ write "hiding "- depend (write "(") $ do- case specs of- [] -> return ()- x:xs -> do- pretty x- forM_ xs $ \spec -> do- write ","- col <- getColumn- len <- prettyColLength spec- maxColumns <- configMaxColumns <$> gets psConfig- if col + len > maxColumns- then newline- else space-- pretty spec- write ")"---- | Return the number of columns between the start and end of a printer.--- Note that if it breaks lines, the line break is not counted; only column is used.--- So you probably only want to use this for single-line printers.-prettyColLength :: (Integral a, Pretty ast) => ast NodeInfo -> Printer State a-prettyColLength x = fst <$> sandbox (do- col <- getColumn- pretty x- col' <- getColumn- return $ fromIntegral $ max (col' - col) 0)---- | Format contexts with spaces and commas between class constraints.-context :: Extend Context-context (CxTuple _ asserts) =- parens $ inter (comma >> space) $ map pretty asserts-context ctx = prettyNoExt ctx---- | Format deriving clauses with spaces and commas between class constraints.-derivings :: Extend Deriving-derivings (Deriving _ instHeads) = do- write "deriving "- go instHeads-- where- go insts- | length insts == 1 = pretty $ head insts- | otherwise = parens $ inter (comma >> space) $ map pretty insts---- | Format function type declarations.-typ :: Extend Type--- For contexts, check whether the context and all following function types--- are on the same line. If they are, print them on the same line; otherwise--- print the context and each argument to the function on separate lines.-typ (TyForall _ mforall (Just ctx) rest) = do- forM_ mforall $ \forallVars -> do- write "forall "- spaced $ map pretty forallVars- write ". "- if all (sameLine ctx) $ collectTypes rest- then do- pretty ctx- write " => "- pretty rest- else do- col <- getColumn- pretty ctx- column (col - 3) $ do- newline- write "=> "- indented 3 $ pretty rest-typ (TyTuple _ boxed types) = writeTuple boxed types-typ ty@(TyFun _ from to) =- -- If the function argument types are on the same line,- -- put the entire function type on the same line.- if all (sameLine from) $ collectTypes ty- then do- pretty from- write " -> "- pretty to- else do- -- If the function argument types are on different lines,- -- write one argument type per line.- col <- getColumn- pretty from- column (col - 3) $ do- newline- write "-> "- indented 3 $ pretty to-typ t = prettyNoExt t--writeTuple :: Pretty ast => Boxed -> [ast NodeInfo] -> Printer State ()-writeTuple boxed vals = parens $ do- boxed'- inter (write ", ") $ map pretty vals- boxed'- where- boxed' =- case boxed of- Boxed -> return ()- Unboxed -> write "#"--sameLine :: (Annotated ast, Annotated ast') => ast NodeInfo -> ast' NodeInfo -> Bool-sameLine x y = line x == line y- where- line :: Annotated ast => ast NodeInfo -> Int- line = startLine . nodeInfoSpan . ann--collectTypes :: Type l -> [Type l]-collectTypes (TyFun _ from to) = from : collectTypes to-collectTypes ty = [ty]--exprs :: Extend Exp-exprs exp@Let{} = letExpr exp-exprs exp@App{} = appExpr exp-exprs exp@Do{} = doExpr exp-exprs exp@List{} = listExpr exp-exprs exp@(InfixApp _ _ (QVarOp _ (UnQual _ (Symbol _ "$"))) _) = dollarExpr exp-exprs exp@(InfixApp _ _ (QVarOp _ (UnQual _ (Symbol _ "<*>"))) _) = applicativeExpr exp-exprs exp@InfixApp{} = opExpr exp-exprs exp@Lambda{} = lambdaExpr exp-exprs exp@Case{} = caseExpr exp-exprs exp@LCase{} = lambdaCaseExpr exp-exprs exp@If{} = ifExpr exp-exprs exp@MultiIf{} = multiIfExpr exp-exprs (RecUpdate _ exp updates) = recUpdateExpr updates (pretty exp) (map prettyCommentCallbacks updates)-exprs (RecConstr _ qname updates) = recUpdateExpr updates (pretty qname) (map prettyCommentCallbacks updates)-exprs (Tuple _ _ exps) = parens $ inter (write ", ") $ map pretty exps-exprs (ListComp _ e qstmt) =- brackets (do space- pretty e- unless (null qstmt)- (do newline- indented (-1)- (write "|")- prefixedLined ","- (map (\x -> do space- pretty x- space)- qstmt)))-exprs exp = prettyNoExt exp--multiIfExpr :: Exp NodeInfo -> Printer State ()-multiIfExpr (MultiIf _ alts) =- withCaseContext True $- depend (write "if ") $- onSeparateLines' (depend (write "|") . pretty) alts-multiIfExpr _ = error "Not a multi if"--letExpr :: Exp NodeInfo -> Printer State ()-letExpr (Let _ binds result) = do- cols <- depend (write "let ") $ do- col <- getColumn-- oldLetBind <- userGets gibianskyLetBind- userModify (\s -> s { gibianskyLetBind = True })- writeWhereBinds binds- userModify (\s -> s { gibianskyLetBind = oldLetBind })-- return $ col - 4- column cols $ do- newline- write "in "- pretty result-letExpr _ = error "Not a let"--keepingColumn :: Printer State () -> Printer State ()-keepingColumn printer = do- eol <- gets psEolComment- when eol newline- col <- getColumn- ind <- gets psIndentLevel- column (max col ind) printer--appExpr :: Exp NodeInfo -> Printer State ()-appExpr app@(App _ f x) = do- prevState <- get- prevLine <- getLineNum- attemptSingleLine singleLine multiLine- curLine <- getLineNum-- -- If the multiline version takes more than two lines,- -- print everything with one argument per line.- when (curLine - prevLine > 1) $ do- -- Restore to before printing.- put prevState-- allArgsSeparate <- not <$> canSingleLine (pretty f)- if allArgsSeparate- then separateArgs app- else keepingColumn $ do- pretty f- newline- indented indentSpaces $ pretty x-- where- singleLine = spaced [pretty f, pretty x]- multiLine = keepingColumn $ do- pretty f- newline- indentOnce- pretty x-- canSingleLine :: Printer State a -> Printer State Bool- canSingleLine printer = do- st <- get- prevLine <- getLineNum- _ <- printer- curLine <- getLineNum- put st- return $ prevLine == curLine-- -- Separate a function application into the function- -- and all of its arguments. Arguments are returned in reverse order.- collectArgs :: Exp NodeInfo -> (Exp NodeInfo, [Exp NodeInfo])- collectArgs (App _ g y) =- let (fun, args) = collectArgs g- in (fun, y : args)- collectArgs nonApp = (nonApp, [])-- separateArgs :: Exp NodeInfo -> Printer State ()- separateArgs expr =- let (fun, args) = collectArgs expr- in keepingColumn $ do- pretty fun- newline- indented indentSpaces $ lined $ map pretty $ reverse args-appExpr _ = error "Not an app"--doExpr :: Exp NodeInfo -> Printer State ()-doExpr (Do _ stmts) = do- write "do"- newline- indented indentSpaces $ onSeparateLines stmts-doExpr _ = error "Not a do"--listExpr :: Exp NodeInfo -> Printer State ()-listExpr (List _ els) = attemptSingleLine (singleLineList els) (multiLineList els)-listExpr _ = error "Not a list"--singleLineList :: Pretty a => [a NodeInfo] -> Printer State ()-singleLineList exps = do- write "["- inter (write ", ") $ map pretty exps- write "]"--multiLineList :: [Exp NodeInfo] -> Printer State ()-multiLineList [] = write "[]"-multiLineList (first:exps) = keepingColumn $ do- write "[ "- pretty first- forM_ exps $ \el -> do- newline- write ", "- pretty el- newline- write "]"--dollarExpr :: Exp NodeInfo -> Printer State ()-dollarExpr (InfixApp _ left op right) = do- pretty left- space- pretty op- if needsNewline right- then do- newline- col <- getColumn- ind <- gets psIndentLevel- column (max col ind + indentSpaces) $ pretty right- else do- space- pretty right-- where- needsNewline Case{} = True- needsNewline exp = lineDelta exp op > 0-dollarExpr _ = error "Not an application"--applicativeExpr :: Exp NodeInfo -> Printer State ()-applicativeExpr exp@InfixApp{} =- case applicativeArgs of- Just (first:second:rest) ->- attemptSingleLine (singleLine first second rest) (multiLine first second rest)- _ -> prettyNoExt exp- where- singleLine :: Exp NodeInfo -> Exp NodeInfo -> [Exp NodeInfo] -> Printer State ()- singleLine first second rest = spaced- [ pretty first- , write "<$>"- , pretty second- , write "<*>"- , inter (write " <*> ") $ map pretty rest- ]-- multiLine :: Exp NodeInfo -> Exp NodeInfo -> [Exp NodeInfo] -> Printer State ()- multiLine first second rest = do- pretty first- depend space $ do- write "<$> "- pretty second- forM_ rest $ \val -> do- newline- write "<*> "- pretty val-- applicativeArgs :: Maybe [Exp NodeInfo]- applicativeArgs = collectApplicativeExps exp-- collectApplicativeExps :: Exp NodeInfo -> Maybe [Exp NodeInfo]- collectApplicativeExps (InfixApp _ left op right)- | isFmap op = return [left, right]- | isAp op = do- start <- collectApplicativeExps left- return $ start ++ [right]- | otherwise = Nothing- collectApplicativeExps _ = Nothing-- isFmap :: QOp NodeInfo -> Bool- isFmap (QVarOp _ (UnQual _ (Symbol _ "<$>"))) = True- isFmap _ = False-- isAp :: QOp NodeInfo -> Bool- isAp (QVarOp _ (UnQual _ (Symbol _ "<*>"))) = True- isAp _ = False-applicativeExpr _ = error "Not an application"--opExpr :: Exp NodeInfo -> Printer State ()-opExpr expr@(InfixApp _ left op right) = keepingColumn $ do- let deltaLeft = lineDelta op left- deltaRight = lineDelta right op-- -- If this starts out as a single line expression, try to keep it as a single line expression. Break- -- it up over multiple lines if it doesn't fit using operator columns, but only when all the- -- operators are the same.- if deltaLeft == 0 && deltaRight == 0 && numOperatorUses op expr >= 2- then attemptSingleLine opSingle opMulti- else userSpecified deltaLeft deltaRight- where- -- Use user-specified spacing for the newlines in the operator- userSpecified deltaLeft deltaRight = do- pretty left-- if deltaLeft == 0- then space- else replicateM_ deltaLeft newline-- pretty op-- if deltaRight == 0- then space- else replicateM_ deltaRight newline-- pretty right-- -- Write the entire infix expression on one line.- opSingle = sequence_ [pretty left, space, pretty op, space, pretty right]-- -- Use operator column layout.- opMulti = do- let opArguments = collectOpArguments op expr- forM_ (init opArguments) $ \arg -> do- pretty arg- space- pretty op- newline- pretty (last opArguments)-- -- Count the number of times an infix operator is used in a row.- numOperatorUses op e = length (collectOpArguments op e) - 1-- -- Collect all arguments to an infix operator.- collectOpArguments op expr'@(InfixApp _ left' op' right')- | void op == void op' = collectOpArguments op left' ++ collectOpArguments op right'- | otherwise = [expr']- collectOpArguments _ expr' = [expr']-opExpr exp = prettyNoExt exp--lambdaExpr :: Exp NodeInfo -> Printer State ()-lambdaExpr (Lambda _ pats exp) = do- write "\\"- spaced $ map pretty pats- write " ->"- if any isBefore $ nodeInfoComments $ ann exp- then multi- else attemptSingleLine (space >> pretty exp) multi-- where multi = do- newline- indented indentSpaces $ pretty exp-- isBefore com = comInfoLocation com == Just Before-lambdaExpr _ = error "Not a lambda"--caseExpr :: Exp NodeInfo -> Printer State ()-caseExpr (Case _ exp alts) = do- depend (write "case ") $ do- pretty exp- write " of"- newline-- writeCaseAlts alts-caseExpr _ = error "Not a case"--lambdaCaseExpr :: Exp NodeInfo -> Printer State ()-lambdaCaseExpr (LCase _ alts) = do- write "\\case"- newline- writeCaseAlts alts-lambdaCaseExpr _ = error "Not a lambda case"--ifExpr :: Exp NodeInfo -> Printer State ()-ifExpr (If _ cond thenExpr elseExpr) =- depend (write "if") $ do- space- pretty cond- newline- write "then "- pretty thenExpr- newline- write "else "- pretty elseExpr-ifExpr _ = error "Not an if statement"--writeCaseAlts :: [Alt NodeInfo] -> Printer State ()-writeCaseAlts alts = do- allSingle <- and <$> mapM isSingle alts- withCaseContext True $ indented indentSpaces $ do- prettyPr <- if allSingle- then do- maxPatLen <- maximum <$> mapM (patternLen . altPattern) alts- return $ prettyCase (Just maxPatLen)- else return $ prettyCase Nothing-- case alts of- [] -> return ()- first:rest -> do- printComments Before first- prettyPr first- printComments After first- forM_ (zip alts rest) $ \(prev, cur) -> do- replicateM_ (max 1 $ lineDelta cur prev) newline- printComments Before cur- prettyPr cur- printComments After cur-- where- isSingle :: Alt NodeInfo -> Printer State Bool- isSingle alt' = fst <$> sandbox- (do- line <- gets psLine- pretty alt'- line' <- gets psLine- return $ not (isGuarded (altRhs alt')) && line == line')-- altPattern :: Alt l -> Pat l- altPattern (Alt _ p _ _) = p-- altRhs :: Alt l -> Rhs l- altRhs (Alt _ _ r _) = r-- isGuarded :: Rhs l -> Bool- isGuarded GuardedRhss{} = True- isGuarded UnGuardedRhs{} = False-- patternLen :: Pat NodeInfo -> Printer State Int- patternLen pat = fromIntegral <$> fst <$> sandbox- (do- col <- getColumn- pretty pat- col' <- getColumn- return $ col' - col)-- prettyCase :: Maybe Int -> Alt NodeInfo -> Printer State ()- prettyCase mpatlen (Alt _ p galts mbinds) = do- -- Padded pattern- case mpatlen of- Just patlen -> do- col <- getColumn- pretty p- col' <- getColumn- replicateM_ (patlen - fromIntegral (col' - col)) space- Nothing -> pretty p-- case galts of- UnGuardedRhs{} -> pretty galts- GuardedRhss{} -> do- newline- indented indentSpaces $ pretty galts-- -- Optional where clause!- forM_ mbinds $ \binds -> do- newline- indented indentSpaces $ depend (write "where ") (pretty binds)--prettyCommentCallbacks :: (Pretty ast,MonadState (PrintState s) m) => ast NodeInfo -> (ComInfoLocation -> m ()) -> m ()-prettyCommentCallbacks a f =- do st <- get- case st of- PrintState{psExtenders = es,psUserState = s} ->- do- printComments Before a- f Before- depend- (case listToMaybe (mapMaybe (makePrinter s) es) of- Just (Printer m) ->- modify (\s' ->- fromMaybe s'- (runIdentity (runMaybeT (execStateT m s'))))- Nothing -> prettyNoExt a)- (f After >> printComments After a)- where makePrinter _ (Extender f) =- case cast a of- Just v -> Just (f v)- Nothing -> Nothing- makePrinter s (CatchAll f) = f s a---recUpdateExpr :: Foldable f => [f NodeInfo] -> Printer State () -> [(ComInfoLocation -> Printer State ()) -> Printer State ()] -> Printer State ()-recUpdateExpr ast expWriter updates- | null updates = do- expWriter- write "{}"- | any hasComments ast = mult- | otherwise = attemptSingleLine single mult-- where- single = do- expWriter- write " { "- inter (write ", ") updates'- write " }"- mult = do- expWriter- newline- indented indentSpaces $ keepingColumn $ do- write "{ "- head updates'- forM_ (tail updates) $ \update -> do- newline- update commaAfterComment- newline- write "}"-- updates' = map ($ const $ return ()) updates--commaAfterComment :: ComInfoLocation -> Printer State ()-commaAfterComment loc = case loc of- Before -> write ", "- After -> return ()--rhss :: Extend Rhs-rhss (UnGuardedRhs rhsLoc exp) = do- letBind <- userGets gibianskyLetBind- let exp'- | lineBreakAfterRhs rhsLoc exp =- indented indentSpaces $ do- newline- pretty exp- | letBind =- depend space (pretty exp)- | otherwise = space >> pretty exp- if letBind- then depend (space >> rhsSeparator) exp'- else space >> rhsSeparator >> exp'-rhss (GuardedRhss _ rs) =- flip onSeparateLines' rs $ \a@(GuardedRhs rhsLoc stmts exp) -> do- let manyStmts = length stmts > 1- remainder = do- if manyStmts then newline else space- rhsSeparator- if not manyStmts && lineBreakAfterRhs rhsLoc exp- then newline >> indented indentSpaces (pretty exp)- else space >> pretty exp- writeStmts =- case stmts of- x:xs -> do- pretty x- forM_ xs $ \x -> write "," >> newline >> pretty x- [] -> return ()-- printComments Before a- if manyStmts- then do- depend (write "| ") writeStmts- remainder- else- depend (write "| ") $ writeStmts >> remainder- printComments After a--lineBreakAfterRhs :: NodeInfo -> Exp NodeInfo -> Bool-lineBreakAfterRhs rhsLoc exp = onNextLine exp- where- -- Cannot use lineDelta because we need to look at rhs start line, not end line- prevLine = srcSpanStartLine . srcInfoSpan . nodeInfoSpan $ rhsLoc- curLine = astStartLine exp- emptyLines = curLine - prevLine-- onNextLine Let{} = True- onNextLine Case{} = True- onNextLine _ = emptyLines > 0--guardedRhs :: Extend GuardedRhs-guardedRhs (GuardedRhs _ stmts exp) = do- indented 1 $ prefixedLined "," (map (\p -> space >> pretty p) stmts)- space- rhsRest exp--rhsRest :: Pretty ast => ast NodeInfo -> Printer State ()-rhsRest exp = do- rhsSeparator- space- pretty exp--stmts :: Extend Stmt-stmts (LetStmt _ binds) = depend (write "let ") (writeWhereBinds binds)-stmts stmt = prettyNoExt stmt--decls :: Extend Decl-decls (DataDecl _ dataOrNew Nothing declHead constructors mayDeriving) = do- depend (pretty dataOrNew >> space) $ do- pretty declHead- case constructors of- [] -> return ()- [x] -> do- write " ="- pretty x- (x:xs) ->- depend space $ do- write "="- pretty x- forM_ xs $ \constructor -> do- newline- write "|"- pretty constructor-- forM_ mayDeriving $ \deriv -> do- newline- indented indentSpaces $ pretty deriv-decls (PatBind _ pat rhs mbinds) = funBody [pat] rhs mbinds-decls (FunBind _ matches) =- flip onSeparateLines' matches $ \match -> do- printComments Before match- (writeName, pat, rhs, mbinds) <- case match of- Match _ name pat rhs mbinds -> return (pretty name, pat, rhs, mbinds)- InfixMatch _ left name pat rhs mbinds -> do- pretty left- space- let writeName = case name of- Symbol _ name' -> string name'- Ident _ name' -> do- write "`"- string name'- write "`"- return (writeName, pat, rhs, mbinds)- writeName- space- funBody pat rhs mbinds- printComments After match-decls (ClassDecl _ ctx dhead fundeps mayDecls) = do- let decls = fromMaybe [] mayDecls- noDecls = null decls-- -- Header- depend (write "class ") $- withCtx ctx $- depend (pretty dhead >> space) $- depend (unless (null fundeps) (write " | " >> commas (map pretty fundeps))) $- unless noDecls (write "where")-- -- Class method declarations- unless noDecls $ do- newline- indentSpaces <- getIndentSpaces- indented indentSpaces (onSeparateLines decls)-decls decl = prettyNoExt decl--qualConDecl :: Extend QualConDecl-qualConDecl (QualConDecl _ tyvars ctx d) =- depend (unless (null (fromMaybe [] tyvars))- (do write " forall "- spaced (map pretty (fromMaybe [] tyvars))- write ". "))- (depend (maybeCtx' ctx)- (pretty d))- where- maybeCtx' = maybe (return ())- (\p ->- pretty p >>- write " =>")--funBody :: [Pat NodeInfo] -> Rhs NodeInfo -> Maybe (Binds NodeInfo) -> Printer State ()-funBody pat rhs mbinds = do- spaced $ map pretty pat-- withCaseContext False $- case rhs of- UnGuardedRhs{} -> pretty rhs- GuardedRhss{} -> do- newline- indented indentSpaces $ pretty rhs-- -- Process the binding group, if it exists.- forM_ mbinds $ \binds -> do- newline- -- Add an extra newline after do blocks.- when (isDoBlock rhs) newline- indented indentSpaces $ do- write "where"- newline- indented indentSpaces $ writeWhereBinds binds--writeWhereBinds :: Binds NodeInfo -> Printer State ()-writeWhereBinds ds@(BDecls _ binds) = do- printComments Before ds- onSeparateLines binds- printComments After ds-writeWhereBinds binds = prettyNoExt binds---- Print all the ASTs on separate lines, respecting user spacing.-onSeparateLines :: (Pretty ast, Annotated ast) => [ast NodeInfo] -> Printer State ()-onSeparateLines = onSeparateLines' pretty--onSeparateLines' :: Annotated ast => (ast NodeInfo -> Printer State ()) -> [ast NodeInfo] -> Printer State ()-onSeparateLines' _ [] = return ()-onSeparateLines' pretty' vals = do- let vals' = map (amap fixSpans) vals- (first:rest) = vals'--- pretty' first- forM_ (zip vals' rest) $ \(prev, cur) -> do- replicateM_ (max 1 $ lineDelta cur prev) newline- pretty' cur--fixSpans :: NodeInfo -> NodeInfo-fixSpans info =- let infoSpan = nodeInfoSpan info- srcSpan = srcInfoSpan infoSpan-- points = srcInfoPoints infoSpan- lastPt = last points-- prevLastPt = last (init points)- prevPtEnd = (srcSpanEndLine prevLastPt, srcSpanEndColumn prevLastPt)-- lastPtEndLoc = (srcSpanEndLine lastPt, srcSpanEndColumn lastPt)- invalidLastPt = srcSpanStartLine lastPt == srcSpanEndLine lastPt &&- srcSpanStartColumn lastPt > srcSpanEndColumn lastPt-- infoEndLoc = (srcSpanEndLine srcSpan, srcSpanEndColumn srcSpan)- in if length points > 1 && lastPtEndLoc == infoEndLoc && invalidLastPt- then info { nodeInfoSpan = infoSpan { srcInfoSpan = setEnd srcSpan prevPtEnd } }- else info- where- setEnd (SrcSpan fname startL startC _ _) (endL, endC) = SrcSpan fname startL startC endL endC---astStartLine :: Annotated ast => ast NodeInfo -> Int-astStartLine decl =- let info = ann decl- comments = nodeInfoComments info- befores = filter ((== Just Before) . comInfoLocation) comments- commentStartLine (Comment _ sp _) = srcSpanStartLine sp- in if null befores- then startLine $ nodeInfoSpan info- else minimum $ map (commentStartLine . comInfoComment) befores--isDoBlock :: Rhs l -> Bool-isDoBlock (UnGuardedRhs _ Do{}) = True-isDoBlock _ = False--condecls :: Extend ConDecl-condecls (ConDecl _ name bangty) =- depend (space >> pretty name) $- forM_ bangty $ \ty -> space >> pretty ty-condecls decl@(RecDecl _ name fields) = if hasComments decl- then multiRec- else attemptSingleLine singleRec multiRec- where- singleRec = space >> depend (pretty name >> space) recBody- multiRec = do- newline- indented indentSpaces $ keepingColumn $ do- pretty name- newline- indented indentSpaces recBody-- recBody = do- write "{ "- writeFields fields- write "}"-- writeFields [] = return ()- writeFields [x] = do- pretty x- eol <- gets psEolComment- unless eol space- writeFields (first:rest) = do- singleLine <- gets (gibianskyForceSingleLine . psUserState)-- pretty first- unless singleLine newline- forM_ rest $ \field -> do- prettyCommentCallbacks field commaAfterComment- unless singleLine newline-- when singleLine space-condecls other = prettyNoExt other--hasComments :: Foldable ast => ast NodeInfo -> Bool-hasComments = any (not . null . nodeInfoComments)--alt :: Extend Alt-alt (Alt _ p rhs mbinds) = do- pretty p- case rhs of- UnGuardedRhs{} -> pretty rhs- GuardedRhss{} -> indented indentSpaces $ pretty rhs- forM_ mbinds $ \binds -> do- newline- indented indentSpaces $- depend (write "where ") (pretty binds)--moduleHead :: Extend ModuleHead-moduleHead (ModuleHead _ name mwarn mexports) = do- forM_ mwarn pretty- write "module "- pretty name- forM_ mexports $ \exports -> do- space- pretty exports- write " where"--exportList :: Extend ExportSpecList-exportList (ExportSpecList _ exports) = do- write "("- if length exports <= maxSingleLineExports- then do- inter (write ", ") $ map pretty exports- write ")"- else indented indentSpaces' $ do- -- First export- let first:rest = exports- newline- pretty first- write ","-- forM_ (zip rest exports) $ \(cur, prev) -> do- replicateM_ (max 1 $ lineDelta cur prev) newline- pretty cur- write ","- newline- write ")"-- where- indentSpaces' = 2 * indentSpaces--lineDelta :: (Annotated ast1, Annotated ast2) => ast1 NodeInfo -> ast2 NodeInfo -> Int-lineDelta cur prev = emptyLines- where- prevLine = srcSpanEndLine . srcInfoSpan . nodeInfoSpan . ann $ prev- curLine = astStartLine cur- emptyLines = curLine - prevLine--fieldUpdate :: Extend FieldUpdate-fieldUpdate (FieldUpdate _ name val) = do- pretty name- write " = "- pretty val-fieldUpdate upd = prettyNoExt upd
src/HIndent/Styles/JohanTibell.hs view
@@ -18,10 +18,10 @@ import Data.Foldable (forM_) import Data.Int import Data.Maybe+import Data.Monoid import HIndent.Pretty-import HIndent.Styles.ChrisDone (infixApp) import HIndent.Types-import Language.Haskell.Exts.Annotated.Syntax+import Language.Haskell.Exts.Syntax import Prelude hiding (exp) --------------------------------------------------------------------------------@@ -537,3 +537,50 @@ (do write "where" newline indented 2 (pretty binds))++infixApp :: Exp NodeInfo+ -> Exp NodeInfo+ -> QOp NodeInfo+ -> Exp NodeInfo+ -> Maybe Int64+ -> Printer s ()+infixApp e a op b indent =+ do (fits,st) <-+ fitsOnOneLine+ (spaced (map (\link ->+ case link of+ OpChainExp e' -> pretty e'+ OpChainLink qop -> pretty qop)+ (flattenOpChain e)))+ if fits+ then put st+ else do prettyWithIndent a+ space+ pretty op+ newline+ case indent of+ Nothing -> prettyWithIndent b+ Just col ->+ do indentSpaces <- getIndentSpaces+ column (col + indentSpaces)+ (prettyWithIndent b)+ where prettyWithIndent e' =+ case e' of+ (InfixApp _ a' op' b') ->+ infixApp e' a' op' b' indent+ _ -> pretty e'++-- | A link in a chain of operator applications.+data OpChainLink l+ = OpChainExp (Exp l)+ | OpChainLink (QOp l)+ deriving (Show)++-- | Flatten a tree of InfixApp expressions into a chain of operator+-- links.+flattenOpChain :: Exp l -> [OpChainLink l]+flattenOpChain (InfixApp _ left op right) =+ flattenOpChain left <>+ [OpChainLink op] <>+ flattenOpChain right+flattenOpChain e = [OpChainExp e]
src/main/Main.hs view
@@ -21,7 +21,7 @@ import Descriptive import Descriptive.Options import GHC.Tuple-import Language.Haskell.Exts.Annotated hiding (Style,style)+import Language.Haskell.Exts hiding (Style,style) import Paths_hindent (version) import System.Directory import System.Environment@@ -33,64 +33,82 @@ -- | Main entry point. main :: IO ()-main =- do args <- getArgs- case consume options (map T.pack args) of- Succeeded (style,exts,mfilepath) ->- case mfilepath of- Just filepath ->- do text <- T.readFile filepath- tmpDir <- getTemporaryDirectory- (fp,h) <- openTempFile tmpDir "hindent.hs"- T.hPutStrLn- h- (either error T.toLazyText (reformat style (Just exts) text))- hFlush h- hClose h- let exdev e = if ioe_errno e == Just ((\(Errno a) -> a) eXDEV)- then copyFile fp filepath >> removeFile fp- else throw e- renameFile fp filepath `catch` exdev- Nothing ->- T.interact (either error T.toLazyText . reformat style (Just exts))- Failed (Wrap (Stopped Version) _) ->- putStrLn ("hindent " ++ showVersion version)- _ ->- error (T.unpack (textDescription (describe options [])))+main = do+ args <- getArgs+ case consume options (map T.pack args) of+ Succeeded (style,exts,mfilepath) ->+ case mfilepath of+ Just filepath -> do+ text <- T.readFile filepath+ tmpDir <- getTemporaryDirectory+ (fp,h) <- openTempFile tmpDir "hindent.hs"+ T.hPutStrLn+ h+ (either+ error+ T.toLazyText+ (reformat style (Just exts) text))+ hFlush h+ hClose h+ let exdev e =+ if ioe_errno e ==+ Just+ ((\(Errno a) ->+ a)+ eXDEV)+ then copyFile fp filepath >> removeFile fp+ else throw e+ renameFile fp filepath `catch` exdev+ Nothing ->+ T.interact+ (either error T.toLazyText . reformat style (Just exts))+ Failed (Wrap (Stopped Version) _) ->+ putStrLn ("hindent " ++ showVersion version)+ Failed (Wrap (Stopped Help) _) -> putStrLn help+ _ -> error help+ where +help =+ "hindent " +++ T.unpack (textDescription (describe options [])) +++ "\nVersion " ++ showVersion version ++ "\n" +++ "The --style option is now ignored, but preserved for backwards-compatibility.\n" +++ "Johan Tibell is the default and only style."+ -- | Options that stop the argument parser.-data Stoppers = Version+data Stoppers = Version | Help deriving (Show) -- | Program options. options :: Monad m => Consumer [Text] (Option Stoppers) m (Style,[Extension],Maybe FilePath)-options =- ver *>- ((,,) <$> style <*> exts <*> file)- where ver =- stop (flag "version" "Print the version" Version)- style =- makeStyle <$> (constant "--style" "Style to print with" () *>- foldr1 (<|>)- (map (\s ->- constant (styleName s)- (styleDescription s)- s)- styles))- <*> lineLen- exts =- fmap getExtensions (many (prefix "X" "Language extension"))- lineLen =- fmap (>>= (readMaybe . T.unpack))- (optional (arg "line-length" "Desired length of lines"))- makeStyle s mlen =- case mlen of+options = ver *> ((,,) <$> style <*> exts <*> file)+ where+ ver = stop (flag "version" "Print the version" Version) *>+ stop (flag "help" "Show help" Help)+ style =+ makeStyle <$>+ fmap+ (const johanTibell)+ (optional+ (constant "--style" "Style to print with" () *>+ anyString "STYLE")) <*>+ lineLen+ exts = fmap getExtensions (many (prefix "X" "Language extension"))+ lineLen =+ fmap+ (>>= (readMaybe . T.unpack))+ (optional (arg "line-length" "Desired length of lines"))+ makeStyle s mlen =+ case mlen of Nothing -> s Just len ->- s {styleDefConfig =- (styleDefConfig s) {configMaxColumns = len}}- file = fmap (fmap T.unpack) (optional (anyString "[<filename>]"))+ s+ { styleDefConfig = (styleDefConfig s)+ { configMaxColumns = len+ }+ }+ file = fmap (fmap T.unpack) (optional (anyString "[<filename>]")) -------------------------------------------------------------------------------- -- Extensions stuff stolen from hlint
src/main/TestGenerate.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE FlexibleContexts #-} module Main(main) where import Control.Monad@@ -50,7 +51,7 @@ writeFile dstFilename contents where- findStyle style = find ((== style). HIndent.styleName) HIndent.styles+ findStyle style = find ((== style). HIndent.styleName) [HIndent.johanTibell] tests style = "test/" ++ style ++ "/" ++ testDir ++ "/" expected style = "test/" ++ style ++ "/" ++ expectedDir ++ "/" expectedFilename filename = take (length filename - 4) filename ++ "exp"
test/Spec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE FlexibleContexts #-} module Main (main) where import Control.Monad@@ -15,7 +16,7 @@ import qualified HIndent styles :: [FilePath]-styles = ["fundamental", "gibiansky", "chris-done", "johan-tibell", "cramer"]+styles = ["johan-tibell"] testDir, expectedDir :: String testDir = "tests"@@ -26,7 +27,7 @@ testStyle :: FilePath -> IO () testStyle style = do- let Just theStyle = find ((== T.pack style) . HIndent.styleName) HIndent.styles+ let Just theStyle = find ((== T.pack style) . HIndent.styleName) [HIndent.johanTibell] testFilenames <- filter (not . isPrefixOf ".") <$> getDirectoryContents tests let expFiles = map ((expected ++) . expectedFilename) testFilenames testFiles = map (tests ++) testFilenames
− test/chris-done/expected/1.exp
@@ -1,11 +0,0 @@-import Data.Text--import Data.Text--import qualified Data.Text as T--import qualified Data.Text (a, b, c)--import Data.Text (a, b, c)--import Data.Text hiding (a, b, c)
− test/chris-done/expected/10.exp
@@ -1,39 +0,0 @@-unless hello $-case thing of- Left a -> 3- Right b -> 5--when hello $-case thing of- Left a -> 3- Right b -> 5--a = - \line -> - case a of- Left a -> a- Right b -> b--map (\x -> x)- [1,2,3]--forM_ lst $ \x -> do putStrLn x--forM_ lst $ \x -> putStrLn x--Value <$> thing <*> secondThing--Value <$> thing <*> secondThing <*> thirdThing <*> fourthThing <*>-Just thisissolong <*>-Just stilllonger--f e = 5- where a = b--a = b- where c = d- e = f--a = b- where c = d- e = f
− test/chris-done/expected/11.exp
@@ -1,56 +0,0 @@-data A- = B -- ^ hi- | C Int -- ^ hi- | D Float -- ^ hi- | E Float- Float -- ^ hi--data A- = B -- ^ hi- -- continuing the comment- | C Int -- ^ hi- | D Float -- ^ hi- | E Float- Float -- ^ hi- -- continuing the comment--a = - case x of- Nothing -> 2- Just something -> 3--a = - case x of- Nothing -> do putStrLn "hi"- Just something -> 3--a = - case x of- Nothing -> - case y of- 1 -> 2- 3 -> 4- Just something -> 3--a = - case x of- Nothing -> 2- Just x -> 10- Just something -> 3--a = - case x of- Nothing -> 2- Just x -> 10- Just something -> do putStrLn "hello"--data X =- X {a :: Int -- ^ hi- ,b :: String -- ^ hi- }--data X =- X {a :: Int -- ^ hi- ,b :: String -- ^ hi- -- continued- }
− test/chris-done/expected/12.exp
@@ -1,123 +0,0 @@-module Main where--module Main where--module Main- ()- where--module Main- ()- where--module Main- (main)- where--module Main- (main- ,main2)- where--module Main- (main- ,main2)- where--module Main- (main- ,main2- ,main3)- where--module Main- (main- ,main2- ,main3- ,main4)- where--module Main- (main- ,main2- ,main3- ,main4)- where--module Main- (main- ,main2- ,main3- ,main4- ,main5)- where--module Main- (main- ,main2- ,main3- ,main4- ,main5)- where--module Main- (main- ,main2- ,main3- ,main4- ,main5- ,main6)- where--module Main- (main- ,main2- ,main3- ,main4- ,main5- ,main6)- where--module Main- (- -- * A thing- main- ,main2- ,- -- * Another thing- main3- ,main4- ,- -- ** Another thing- main5)- where--module Main- (- -- * A thing- main- ,main2- ,- -- * Another thing- main3- ,main4- ,- -- ** Another thing- main5)- where--module Main- (main)- where->-import Text.Hello--module Main- (main- ,main2- ,main3- ,main4- ,main5)- where->-import Text.Hello
− test/chris-done/expected/13.exp
@@ -1,27 +0,0 @@-a = b- where blah = blah- -- hello- -- bye- hello = hello--a = b- where blah = blah- -- bye- hello = hello--foo = x -- test- where x = blah--foo = x- where - -- another test- x = blah--f = - case undefined of- Just p- -- If it's the potato.- | zot -> undefined- |- -- The geriatric concumbine.- otherwise -> hael
− test/chris-done/expected/14.exp
@@ -1,10 +0,0 @@-x = \y -> y--(1,2)--f x = 3-f x = 3--f x- | x == y = 3- | x == y = 3
− test/chris-done/expected/15.exp
@@ -1,42 +0,0 @@-a = - veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = - veryLongLongLongName veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = - veryLongLongLongName veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = - veryLongLongLongName veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = - veryLongLongLongName veryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--tests = - hello [name "space space space space space space space space space space space" thing- ,name "space space space space space space space space space space space" thing- ,name "space space space space space space space space space space space" thing]--tests = - hello goodbye- [name "space space space space space space space space space space space" thing- ,name "space space space space space space space space space space space" thing- ,name "space space space space space space space space space space space" thing]
− test/chris-done/expected/16.exp
@@ -1,3 +0,0 @@-instance A B where- f x = 3- f y = 3
− test/chris-done/expected/17.exp
@@ -1,3 +0,0 @@-type EventSource a = (AddHandler a,a -> IO ())--type EventSource a = (AddHandler a,a -> IO ())
− test/chris-done/expected/18.exp
@@ -1,19 +0,0 @@-a = b {c = "d"}--a = - b {c = "d"- ,e = "f"}--longLines = - longLines {longLines = "word word word word"- ,wordWordWordWord = "long lines long long long"}--a = B {c = "d"}--a = - B {c = "d"- ,e = "f"}--longLines = - LongLines {longLines = "word word word word"- ,wordWordWordWord = "long lines long long long"}
− test/chris-done/expected/19.exp
@@ -1,15 +0,0 @@-value = value- where b = - case x of- x -> x- y -> y- a :: b- a = 3--value = value- where b = - case x of- x -> x- y -> y- a :: b- a = 3
− test/chris-done/expected/2.exp
@@ -1,30 +0,0 @@-fun :: a -> b--fun :: a -> f b -> g c d--fun :: Class a- => a -> b -> c--fun :: (Class a- ,Class b)- => a -> b -> c--fun :: a -> b -> c--fun :: a -> b -> c--fun :: a -> b -> c--fun :: a- -> b -- ^ Hello- -> c--fun :: a -> b -> c -- ^ Hello--fun :: (Class a- ,Class b)- => a -> b -> c -- ^ Hello--fun :: (Class a- ,Class b)- => a -> b -> c -- ^ Hello
− test/chris-done/expected/20.exp
@@ -1,3 +0,0 @@-f = \ ~a -> undefined--f = \ !a -> undefined
− test/chris-done/expected/3.exp
@@ -1,45 +0,0 @@-let x = y- z = w-in x--let x = y- z = w-in x--a = - let x = y- z = w- in x--a = - let x = y- z = w- in x--let x = y- z = w-in x--let z = w-in x--a = - let z = w- in x--a = - let z = w- in x--f x = - let g x = 5- g x = 5- in 3--f = - let y = z- in z--f x = - let y = z- in z
− test/chris-done/expected/4.exp
@@ -1,51 +0,0 @@-data A =- B --data A =- B -- ^ Hello--data A =- B -- ^ Hello--data A =- B -- ^ Hello--data A- = B - | C --data A- = B - | C - | D --data A- = B - | C - | D --data A- = B - | C - | D --data A- = B - | C - | D - deriving (Show)--data A- = B - | C - | D - deriving (Show,Eq)--data A =- B Int- deriving (Show,Eq)--data A- = B Int- | C String- deriving (Show,Eq)
− test/chris-done/expected/5.exp
@@ -1,45 +0,0 @@-data A =- B {field :: Int}--data A =- B {field :: Int- ,field2 :: Char}--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}- deriving (Show)--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}- deriving (Show)--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}- deriving (Show,Eq)--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}- deriving (Show,Eq)--data A =- B {field :: Int -- ^ Field 1- }--data A =- B {field :: Int -- ^ Field 1- ,field2 :: Char -- ^ field 2- ,field3 :: String}- deriving (Show)
− test/chris-done/expected/6.exp
@@ -1,45 +0,0 @@-a = - case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = - case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = - case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = - case f x of- Nothing -> 1- Just x -> 3--a = - case f x of- Nothing -> 1- Just x -> 3--a = - case f x of- Nothing -> 1- Just x -> 3--a = - case f x of- Nothing -> do return 3- Just x -> return ()--a = - case f x of- Nothing -> do return 3- Just x -> do return 5
− test/chris-done/expected/7.exp
@@ -1,23 +0,0 @@-a = b- where value = 3- value' = 5--a = b- where value = 3- value' = 5--a = b- where value = 3- value' = 5--a = b- where value = 3- value' = 5--a = do return ()- where value = 3- value' = 5--a = do return ()- where value = 3- value' = 5
− test/chris-done/expected/8.exp
@@ -1,29 +0,0 @@-a = [1,2,3]--a = [1,2,3]--a = [1,2,3]--a = - [Just theRightAnswerWithAVeryLongLine- ,Just theRightAnswerWithAVeryLongLine- ,Just theRightAnswerWithAVeryLongLine- ,Nothing]--a = - [Just theRightAnswerWithAVeryLongLine- ,Just theRightAnswerWithAVeryLongLine- ,Just theRightAnswerWithAVeryLongLine- ,Nothing]--a = - [Just theRightAnswerWithAVeryLongLine- ,Just theRightAnswerWithAVeryLongLine- ,Just theRightAnswerWithAVeryLongLine- ,Nothing]--a = - [Just theRightAnswerWithAVeryLongLine- ,Just theRightAnswerWithAVeryLongLine- ,Just theRightAnswerWithAVeryLongLine- ,Nothing]
− test/chris-done/expected/9.exp
@@ -1,16 +0,0 @@-import Data.Attoparsec.ByteString-import Data.Attoparsec.Expr-import Data.ByteString (split)--import Data.Attoparsec.ByteString-import qualified Data.Attoparsec.Expr as X-import Data.ByteString (split)--main :: IO ()-main = return ()--main :: IO ()-main = return ()--main :: a -> b -> c-main = return ()
− test/chris-done/tests/1.test
@@ -1,11 +0,0 @@-import Data.Text--import Data.Text--import qualified Data.Text as T--import qualified Data.Text (a, b, c)--import Data.Text (a, b, c)--import Data.Text hiding (a, b, c)
− test/chris-done/tests/10.test
@@ -1,41 +0,0 @@-unless hello $- case thing of- Left a -> 3- Right b -> 5--when hello $- case thing of- Left a -> 3- Right b -> 5--a = \line ->- case a of- Left a -> a- Right b -> b--map (\x -> x) [1, 2, 3]--forM_ lst $ \x -> do- putStrLn x--forM_ lst $ \x ->- putStrLn x--Value <$> thing <*> secondThing--Value <$> thing <*> secondThing <*> thirdThing <*> fourthThing <*> Just thisissolong <*> Just stilllonger--f e = 5- where- a = b--a = b- where- c = d- e = f--a = b- where- c = d-- e = f
− test/chris-done/tests/11.test
@@ -1,46 +0,0 @@-data A = B -- ^ hi- | C Int -- ^ hi- | D Float -- ^ hi- | E Float Float -- ^ hi--data A = B -- ^ hi- -- continuing the comment- | C Int -- ^ hi- | D Float -- ^ hi- | E Float Float -- ^ hi- -- continuing the comment--a = case x of- Nothing -> 2- Just something -> 3--a = case x of- Nothing -> do- putStrLn "hi"- Just something -> 3--a = case x of- Nothing -> case y of- 1 -> 2- 3 -> 4- Just something -> 3--a = case x of- Nothing -> 2- Just x -> 10- Just something -> 3--a = case x of- Nothing -> 2- Just x -> 10- Just something -> do- putStrLn "hello"--data X = X { a :: Int -- ^ hi- , b :: String -- ^ hi- }--data X = X { a :: Int -- ^ hi- , b :: String -- ^ hi- -- continued- }
− test/chris-done/tests/12.test
@@ -1,86 +0,0 @@-module Main where--module Main- where--module Main () where--module Main (- ) where--module Main (main) where--module Main (main, main2) where--module Main (main,- main2) where--module Main (main, main2, main3) where--module Main (main, main2, main3, main4) where--module Main (main,- main2, main3,- main4) where--module Main (- main,- main2,- main3,- main4,- main5,- ) where--module Main ( main, main2, main3, main4,- main5,- ) where--module Main (- main,- main2,- main3,- main4,- main5,- main6,- ) where--module Main (- main, main2, main3, main4, main5, main6,- ) where--module Main (- -- * A thing- main,- main2,-- -- * Another thing- main3,- main4,-- -- ** Another thing- main5,- ) where--module Main (- -- * A thing- main, main2,-- -- * Another thing- main3, main4,-- -- ** Another thing- main5,) where--module Main (main) where->-import Text.Hello--module Main (- main,- main2,- main3,- main4,- main5,- ) where->-import Text.Hello
− test/chris-done/tests/13.test
@@ -1,29 +0,0 @@-a = b- where- blah = blah-- -- hello- -- bye- hello = hello--a = b- where- blah = blah-- -- bye- hello = hello--foo = x -- test- where- x = blah--foo = x- where -- another test- x = blah--f = case undefined of- Just p- -- If it's the potato.- | zot -> undefined- -- The geriatric concumbine.- | otherwise -> hael
− test/chris-done/tests/14.test
@@ -1,10 +0,0 @@-x = \y -> y--(1, 2)--f x = 3-f x = 3--f x- | x == y = 3- | x == y = 3
− test/chris-done/tests/15.test
@@ -1,21 +0,0 @@-a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--tests = hello- [ name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- ]--tests = hello goodbye- [ name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- ]
− test/chris-done/tests/16.test
@@ -1,3 +0,0 @@-instance A B where- f x = 3- f y = 3
− test/chris-done/tests/17.test
@@ -1,4 +0,0 @@-type EventSource a = (AddHandler a, a -> IO ())--type EventSource a = (AddHandler a,- a -> IO ())
− test/chris-done/tests/18.test
@@ -1,11 +0,0 @@-a = b { c = "d" }--a = b { c = "d", e = "f" }--longLines = longLines { longLines = "word word word word", wordWordWordWord = "long lines long long long" }--a = B { c = "d" }--a = B { c = "d", e = "f" }--longLines = LongLines { longLines = "word word word word", wordWordWordWord = "long lines long long long" }
− test/chris-done/tests/19.test
@@ -1,16 +0,0 @@-value = value- where- b = case x of- x -> x- y -> y- a :: b- a = 3--value = value- where- b = case x of- x -> x- y -> y-- a :: b- a = 3
− test/chris-done/tests/2.test
@@ -1,32 +0,0 @@-fun :: a -> b--fun :: a -> f b -> g c d--fun :: Class a => a -> b -> c--fun :: (Class a, Class b) => a -> b -> c--fun :: a- -> b- -> c--fun :: a- -> b- -> c--fun :: a- -> b- -> c--fun :: a -> b -- ^ Hello- -> c--fun :: a -> b- -> c -- ^ Hello--fun :: (Class a, Class b) => a -> b- -> c -- ^ Hello--fun :: (Class a, Class b) =>- a -> b- -> c -- ^ Hello
− test/chris-done/tests/20.test
@@ -1,3 +0,0 @@-f = \ ~a -> undefined--f = \ !a -> undefined
− test/chris-done/tests/3.test
@@ -1,38 +0,0 @@-let x = y- z = w in x--let x = y- z = w- in x--a = let x = y- z = w- in x--a = let- x = y- z = w- in x--let- x = y- z = w in x--let- z = w in x--a = let- z = w- in x--a = let z = w- in x--f x =- let g x = 5- g x = 5- in 3--f = let y = z in z--f x = let y = z in z
− test/chris-done/tests/4.test
@@ -1,36 +0,0 @@-data A = B--data A = B -- ^ Hello--data A = - B -- ^ Hello--data A- = B -- ^ Hello--data A = B | C--data A = B | C | D--data A = B | C - | D--data A = B - | C - | D--data A = B - | C - | D- deriving Show--data A = B - | C - | D- deriving (Show, Eq)--data A = B Int- deriving (Show, Eq)--data A = B Int | C String- deriving (Show, Eq)
− test/chris-done/tests/5.test
@@ -1,27 +0,0 @@-data A = B { field :: Int }--data A = B { field :: Int, field2 :: Char }--data A = B { field :: Int, field2 :: Char, field3 :: String }--data A = B { field :: Int,- field2 :: Char, field3 :: String } deriving Show--data A = B { field :: Int,- field2 :: Char,- field3 :: String } deriving Show--data A = B { field :: Int- , field2 :: Char- , field3 :: String } deriving (Show, Eq)--data A = B { field :: Int- , field2 :: Char- , field3 :: String } deriving (Show, Eq)--data A = B { field :: Int -- ^ Field 1- }--data A = B { field :: Int, -- ^ Field 1- field2 :: Char, -- ^ field 2- field3 :: String } deriving Show
− test/chris-done/tests/6.test
@@ -1,41 +0,0 @@-a = case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case - f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> do- return 3- Just x -> return ()--a = case f x of- Nothing -> do- return 3- Just x -> do- return 5
− test/chris-done/tests/7.test
@@ -1,30 +0,0 @@-a = b- where- value = 3- value' = 5--a = b where- value = 3- value' = 5--a = b- where value = 3- value' = 5--a =- b where- value = 3- value' = 5--a = do- return ()-- where- value = 3- value' = 5--a = do- return ()- where- value = 3- value' = 5
− test/chris-done/tests/8.test
@@ -1,24 +0,0 @@-a = [1, 2, 3]--a = [1, 2- , 3]--a = [ 1- , 2- , 3]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing- ]--a = [Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine, Nothing]--a = [ Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine, Nothing]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing]
− test/chris-done/tests/9.test
@@ -1,19 +0,0 @@-import Data.Attoparsec.ByteString-import Data.Attoparsec.Expr-import Data.ByteString (split)--import Data.Attoparsec.ByteString-import qualified Data.Attoparsec.Expr as X-import Data.ByteString (split)--main :: IO ()-main = return ()--main :: IO ()-main =- return ()--main :: a -> b- -> c-main =- return ()
− test/fundamental/expected/1.exp
@@ -1,11 +0,0 @@-import Data.Text--import Data.Text--import qualified Data.Text as T--import qualified Data.Text (a, b, c)--import Data.Text (a, b, c)--import Data.Text hiding (a, b, c)
− test/fundamental/expected/10.exp
@@ -1,63 +0,0 @@-unless- hello $ case thing of- Left a -> - 3- Right b -> - 5--when- hello $ case thing of- Left a -> - 3- Right b -> - 5--a = - \line -> - case a of- Left a -> - a- Right b -> - b--map- (\x -> - x)- [1- ,2- ,3]--forM_- lst $ \x -> - do putStrLn- x--forM_- lst $ \x -> - putStrLn- x--Value <$> thing <*> secondThing--Value <$> thing <*> secondThing <*> thirdThing <*> fourthThing <*> Just- thisissolong <*> Just- stilllonger--f e = - 5- where a = - b--a = - b- where c = - d- e = - f--a = - b- where c = - d- e = - f
− test/fundamental/expected/11.exp
@@ -1,71 +0,0 @@-data A- = B -- ^ hi- | C Int -- ^ hi- | D Float -- ^ hi- | E Float- Float -- ^ hi--data A- = B -- ^ hi- -- continuing the comment- | C Int -- ^ hi- | D Float -- ^ hi- | E Float- Float -- ^ hi- -- continuing the comment--a = - case x of- Nothing -> - 2- Just something -> - 3--a = - case x of- Nothing -> - do putStrLn- "hi"- Just something -> - 3--a = - case x of- Nothing -> - case y of- 1 -> - 2- 3 -> - 4- Just something -> - 3--a = - case x of- Nothing -> - 2- Just x -> - 10- Just something -> - 3--a = - case x of- Nothing -> - 2- Just x -> - 10- Just something -> - do putStrLn- "hello"--data X =- X {a :: Int -- ^ hi- ,b :: String -- ^ hi- }--data X =- X {a :: Int -- ^ hi- ,b :: String -- ^ hi- -- continued- }
− test/fundamental/expected/12.exp
@@ -1,123 +0,0 @@-module Main where--module Main where--module Main- ()- where--module Main- ()- where--module Main- (main)- where--module Main- (main- ,main2)- where--module Main- (main- ,main2)- where--module Main- (main- ,main2- ,main3)- where--module Main- (main- ,main2- ,main3- ,main4)- where--module Main- (main- ,main2- ,main3- ,main4)- where--module Main- (main- ,main2- ,main3- ,main4- ,main5)- where--module Main- (main- ,main2- ,main3- ,main4- ,main5)- where--module Main- (main- ,main2- ,main3- ,main4- ,main5- ,main6)- where--module Main- (main- ,main2- ,main3- ,main4- ,main5- ,main6)- where--module Main- (- -- * A thing- main- ,main2- ,- -- * Another thing- main3- ,main4- ,- -- ** Another thing- main5)- where--module Main- (- -- * A thing- main- ,main2- ,- -- * Another thing- main3- ,main4- ,- -- ** Another thing- main5)- where--module Main- (main)- where->-import Text.Hello--module Main- (main- ,main2- ,main3- ,main4- ,main5)- where->-import Text.Hello
− test/fundamental/expected/13.exp
@@ -1,39 +0,0 @@-a = - b- where blah = - blah- -- hello- -- bye- hello = - hello--a = - b- where blah = - blah- -- bye- hello = - hello--foo = - x -- test- where x = - blah--foo = - x- where - -- another test- x = - blah--f = - case undefined of- Just p- -- If it's the potato.- | zot -> - undefined- |- -- The geriatric concumbine.- otherwise -> - hael
− test/fundamental/expected/14.exp
@@ -1,17 +0,0 @@-x = - \y -> - y--(1-,2)--f x = - 3-f x = - 3--f x- | x == y = - 3- | x == y = - 3
− test/fundamental/expected/15.exp
@@ -1,63 +0,0 @@-a = - veryLongLongLongName- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = - veryLongLongLongName- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = - veryLongLongLongName- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = - veryLongLongLongName- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = - veryLongLongLongName- veryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--tests = - hello- [name- "space space space space space space space space space space space"- thing- ,name- "space space space space space space space space space space space"- thing- ,name- "space space space space space space space space space space space"- thing]--tests = - hello- goodbye- [name- "space space space space space space space space space space space"- thing- ,name- "space space space space space space space space space space space"- thing- ,name- "space space space space space space space space space space space"- thing]
− test/fundamental/expected/16.exp
@@ -1,5 +0,0 @@-instance A B where- f x = - 3- f y = - 3
− test/fundamental/expected/17.exp
@@ -1,3 +0,0 @@-type EventSource a = (AddHandler a,a -> IO ())--type EventSource a = (AddHandler a,a -> IO ())
− test/fundamental/expected/18.exp
@@ -1,31 +0,0 @@-a = - b {c = - "d"}--a = - b {c = - "d"- ,e = - "f"}--longLines = - longLines {longLines = - "word word word word"- ,wordWordWordWord = - "long lines long long long"}--a = - B {c = - "d"}--a = - B {c = - "d"- ,e = - "f"}--longLines = - LongLines {longLines = - "word word word word"- ,wordWordWordWord = - "long lines long long long"}
− test/fundamental/expected/19.exp
@@ -1,23 +0,0 @@-value = - value- where b = - case x of- x -> - x- y -> - y- a :: b- a = - 3--value = - value- where b = - case x of- x -> - x- y -> - y- a :: b- a = - 3
− test/fundamental/expected/2.exp
@@ -1,29 +0,0 @@-fun :: a -> b--fun :: a -> f b -> g c d--fun :: Class a =>- a -> b -> c--fun :: (Class a- ,Class b) =>- a -> b -> c--fun :: a -> b -> c--fun :: a -> b -> c--fun :: a -> b -> c--fun :: a -> b -- ^ Hello- -> c--fun :: a -> b -> c -- ^ Hello--fun :: (Class a- ,Class b) =>- a -> b -> c -- ^ Hello--fun :: (Class a- ,Class b) =>- a -> b -> c -- ^ Hello
− test/fundamental/expected/3.exp
@@ -1,62 +0,0 @@-let x = - y- z = - w-in x--let x = - y- z = - w-in x--a = - let x = - y- z = - w- in x--a = - let x = - y- z = - w- in x--let x = - y- z = - w-in x--let z = - w-in x--a = - let z = - w- in x--a = - let z = - w- in x--f x = - let g x = - 5- g x = - 5- in 3--f = - let y = - z- in z--f x = - let y = - z- in z
− test/fundamental/expected/4.exp
@@ -1,51 +0,0 @@-data A =- B --data A =- B -- ^ Hello--data A =- B -- ^ Hello--data A =- B -- ^ Hello--data A- = B - | C --data A- = B - | C - | D --data A- = B - | C - | D --data A- = B - | C - | D --data A- = B - | C - | D - deriving (Show)--data A- = B - | C - | D - deriving (Show,Eq)--data A =- B Int- deriving (Show,Eq)--data A- = B Int- | C String- deriving (Show,Eq)
− test/fundamental/expected/5.exp
@@ -1,45 +0,0 @@-data A =- B {field :: Int}--data A =- B {field :: Int- ,field2 :: Char}--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}- deriving (Show)--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}- deriving (Show)--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}- deriving (Show,Eq)--data A =- B {field :: Int- ,field2 :: Char- ,field3 :: String}- deriving (Show,Eq)--data A =- B {field :: Int -- ^ Field 1- }--data A =- B {field :: Int -- ^ Field 1- ,field2 :: Char -- ^ field 2- ,field3 :: String}- deriving (Show)
− test/fundamental/expected/6.exp
@@ -1,79 +0,0 @@-a = - case f- x of- 1 -> - 1- 2 -> - 3- 3 -> - 4- _ -> - 100--a = - case f- x of- 1 -> - 1- 2 -> - 3- 3 -> - 4- _ -> - 100--a = - case f- x of- 1 -> - 1- 2 -> - 3- 3 -> - 4- _ -> - 100--a = - case f- x of- Nothing -> - 1- Just x -> - 3--a = - case f- x of- Nothing -> - 1- Just x -> - 3--a = - case f- x of- Nothing -> - 1- Just x -> - 3--a = - case f- x of- Nothing -> - do return- 3- Just x -> - return- ()--a = - case f- x of- Nothing -> - do return- 3- Just x -> - do return- 5
− test/fundamental/expected/7.exp
@@ -1,43 +0,0 @@-a = - b- where value = - 3- value' = - 5--a = - b- where value = - 3- value' = - 5--a = - b- where value = - 3- value' = - 5--a = - b- where value = - 3- value' = - 5--a = - do return- ()- where value = - 3- value' = - 5--a = - do return- ()- where value = - 3- value' = - 5
− test/fundamental/expected/8.exp
@@ -1,50 +0,0 @@-a = - [1- ,2- ,3]--a = - [1- ,2- ,3]--a = - [1- ,2- ,3]--a = - [Just- theRightAnswerWithAVeryLongLine- ,Just- theRightAnswerWithAVeryLongLine- ,Just- theRightAnswerWithAVeryLongLine- ,Nothing]--a = - [Just- theRightAnswerWithAVeryLongLine- ,Just- theRightAnswerWithAVeryLongLine- ,Just- theRightAnswerWithAVeryLongLine- ,Nothing]--a = - [Just- theRightAnswerWithAVeryLongLine- ,Just- theRightAnswerWithAVeryLongLine- ,Just- theRightAnswerWithAVeryLongLine- ,Nothing]--a = - [Just- theRightAnswerWithAVeryLongLine- ,Just- theRightAnswerWithAVeryLongLine- ,Just- theRightAnswerWithAVeryLongLine- ,Nothing]
− test/fundamental/expected/9.exp
@@ -1,22 +0,0 @@-import Data.Attoparsec.ByteString-import Data.Attoparsec.Expr-import Data.ByteString (split)--import Data.Attoparsec.ByteString-import qualified Data.Attoparsec.Expr as X-import Data.ByteString (split)--main :: IO ()-main = - return- ()--main :: IO ()-main = - return- ()--main :: a -> b -> c-main = - return- ()
− test/fundamental/tests/1.test
@@ -1,11 +0,0 @@-import Data.Text--import Data.Text--import qualified Data.Text as T--import qualified Data.Text (a, b, c)--import Data.Text (a, b, c)--import Data.Text hiding (a, b, c)
− test/fundamental/tests/10.test
@@ -1,41 +0,0 @@-unless hello $- case thing of- Left a -> 3- Right b -> 5--when hello $- case thing of- Left a -> 3- Right b -> 5--a = \line ->- case a of- Left a -> a- Right b -> b--map (\x -> x) [1, 2, 3]--forM_ lst $ \x -> do- putStrLn x--forM_ lst $ \x ->- putStrLn x--Value <$> thing <*> secondThing--Value <$> thing <*> secondThing <*> thirdThing <*> fourthThing <*> Just thisissolong <*> Just stilllonger--f e = 5- where- a = b--a = b- where- c = d- e = f--a = b- where- c = d-- e = f
− test/fundamental/tests/11.test
@@ -1,46 +0,0 @@-data A = B -- ^ hi- | C Int -- ^ hi- | D Float -- ^ hi- | E Float Float -- ^ hi--data A = B -- ^ hi- -- continuing the comment- | C Int -- ^ hi- | D Float -- ^ hi- | E Float Float -- ^ hi- -- continuing the comment--a = case x of- Nothing -> 2- Just something -> 3--a = case x of- Nothing -> do- putStrLn "hi"- Just something -> 3--a = case x of- Nothing -> case y of- 1 -> 2- 3 -> 4- Just something -> 3--a = case x of- Nothing -> 2- Just x -> 10- Just something -> 3--a = case x of- Nothing -> 2- Just x -> 10- Just something -> do- putStrLn "hello"--data X = X { a :: Int -- ^ hi- , b :: String -- ^ hi- }--data X = X { a :: Int -- ^ hi- , b :: String -- ^ hi- -- continued- }
− test/fundamental/tests/12.test
@@ -1,86 +0,0 @@-module Main where--module Main- where--module Main () where--module Main (- ) where--module Main (main) where--module Main (main, main2) where--module Main (main,- main2) where--module Main (main, main2, main3) where--module Main (main, main2, main3, main4) where--module Main (main,- main2, main3,- main4) where--module Main (- main,- main2,- main3,- main4,- main5,- ) where--module Main ( main, main2, main3, main4,- main5,- ) where--module Main (- main,- main2,- main3,- main4,- main5,- main6,- ) where--module Main (- main, main2, main3, main4, main5, main6,- ) where--module Main (- -- * A thing- main,- main2,-- -- * Another thing- main3,- main4,-- -- ** Another thing- main5,- ) where--module Main (- -- * A thing- main, main2,-- -- * Another thing- main3, main4,-- -- ** Another thing- main5,) where--module Main (main) where->-import Text.Hello--module Main (- main,- main2,- main3,- main4,- main5,- ) where->-import Text.Hello
− test/fundamental/tests/13.test
@@ -1,29 +0,0 @@-a = b- where- blah = blah-- -- hello- -- bye- hello = hello--a = b- where- blah = blah-- -- bye- hello = hello--foo = x -- test- where- x = blah--foo = x- where -- another test- x = blah--f = case undefined of- Just p- -- If it's the potato.- | zot -> undefined- -- The geriatric concumbine.- | otherwise -> hael
− test/fundamental/tests/14.test
@@ -1,10 +0,0 @@-x = \y -> y--(1, 2)--f x = 3-f x = 3--f x- | x == y = 3- | x == y = 3
− test/fundamental/tests/15.test
@@ -1,21 +0,0 @@-a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--tests = hello- [ name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- ]--tests = hello goodbye- [ name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- ]
− test/fundamental/tests/16.test
@@ -1,3 +0,0 @@-instance A B where- f x = 3- f y = 3
− test/fundamental/tests/17.test
@@ -1,4 +0,0 @@-type EventSource a = (AddHandler a, a -> IO ())--type EventSource a = (AddHandler a,- a -> IO ())
− test/fundamental/tests/18.test
@@ -1,11 +0,0 @@-a = b { c = "d" }--a = b { c = "d", e = "f" }--longLines = longLines { longLines = "word word word word", wordWordWordWord = "long lines long long long" }--a = B { c = "d" }--a = B { c = "d", e = "f" }--longLines = LongLines { longLines = "word word word word", wordWordWordWord = "long lines long long long" }
− test/fundamental/tests/19.test
@@ -1,16 +0,0 @@-value = value- where- b = case x of- x -> x- y -> y- a :: b- a = 3--value = value- where- b = case x of- x -> x- y -> y-- a :: b- a = 3
− test/fundamental/tests/2.test
@@ -1,32 +0,0 @@-fun :: a -> b--fun :: a -> f b -> g c d--fun :: Class a => a -> b -> c--fun :: (Class a, Class b) => a -> b -> c--fun :: a- -> b- -> c--fun :: a- -> b- -> c--fun :: a- -> b- -> c--fun :: a -> b -- ^ Hello- -> c--fun :: a -> b- -> c -- ^ Hello--fun :: (Class a, Class b) => a -> b- -> c -- ^ Hello--fun :: (Class a, Class b) =>- a -> b- -> c -- ^ Hello
− test/fundamental/tests/3.test
@@ -1,38 +0,0 @@-let x = y- z = w in x--let x = y- z = w- in x--a = let x = y- z = w- in x--a = let- x = y- z = w- in x--let- x = y- z = w in x--let- z = w in x--a = let- z = w- in x--a = let z = w- in x--f x =- let g x = 5- g x = 5- in 3--f = let y = z in z--f x = let y = z in z
− test/fundamental/tests/4.test
@@ -1,36 +0,0 @@-data A = B--data A = B -- ^ Hello--data A = - B -- ^ Hello--data A- = B -- ^ Hello--data A = B | C--data A = B | C | D--data A = B | C - | D--data A = B - | C - | D--data A = B - | C - | D- deriving Show--data A = B - | C - | D- deriving (Show, Eq)--data A = B Int- deriving (Show, Eq)--data A = B Int | C String- deriving (Show, Eq)
− test/fundamental/tests/5.test
@@ -1,27 +0,0 @@-data A = B { field :: Int }--data A = B { field :: Int, field2 :: Char }--data A = B { field :: Int, field2 :: Char, field3 :: String }--data A = B { field :: Int,- field2 :: Char, field3 :: String } deriving Show--data A = B { field :: Int,- field2 :: Char,- field3 :: String } deriving Show--data A = B { field :: Int- , field2 :: Char- , field3 :: String } deriving (Show, Eq)--data A = B { field :: Int- , field2 :: Char- , field3 :: String } deriving (Show, Eq)--data A = B { field :: Int -- ^ Field 1- }--data A = B { field :: Int, -- ^ Field 1- field2 :: Char, -- ^ field 2- field3 :: String } deriving Show
− test/fundamental/tests/6.test
@@ -1,41 +0,0 @@-a = case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case - f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> do- return 3- Just x -> return ()--a = case f x of- Nothing -> do- return 3- Just x -> do- return 5
− test/fundamental/tests/7.test
@@ -1,30 +0,0 @@-a = b- where- value = 3- value' = 5--a = b where- value = 3- value' = 5--a = b- where value = 3- value' = 5--a =- b where- value = 3- value' = 5--a = do- return ()-- where- value = 3- value' = 5--a = do- return ()- where- value = 3- value' = 5
− test/fundamental/tests/8.test
@@ -1,24 +0,0 @@-a = [1, 2, 3]--a = [1, 2- , 3]--a = [ 1- , 2- , 3]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing- ]--a = [Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine, Nothing]--a = [ Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine, Nothing]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing]
− test/fundamental/tests/9.test
@@ -1,19 +0,0 @@-import Data.Attoparsec.ByteString-import Data.Attoparsec.Expr-import Data.ByteString (split)--import Data.Attoparsec.ByteString-import qualified Data.Attoparsec.Expr as X-import Data.ByteString (split)--main :: IO ()-main = return ()--main :: IO ()-main =- return ()--main :: a -> b- -> c-main =- return ()
− test/gibiansky/expected/1.exp
@@ -1,11 +0,0 @@-import Data.Text--import Data.Text--import qualified Data.Text as T--import qualified Data.Text (a, b, c)--import Data.Text (a, b, c)--import Data.Text hiding (a, b, c)
− test/gibiansky/expected/10.exp
@@ -1,44 +0,0 @@-unless hello $- case thing of- Left a -> 3- Right b -> 5--when hello $- case thing of- Left a -> 3- Right b -> 5--a = \line -> case a of- Left a -> a- Right b -> b--map (\x -> x) [1, 2, 3]--forM_ lst $ \x -> do- putStrLn x--forM_ lst $ \x -> putStrLn x--Value <$> thing <*> secondThing--Value <$> thing- <*> secondThing- <*> thirdThing- <*> fourthThing- <*> Just thisissolong- <*> Just stilllonger--f e = 5- where- a = b--a = b- where- c = d- e = f--a = b- where- c = d-- e = f
− test/gibiansky/expected/11.exp
@@ -1,53 +0,0 @@-data A = B -- ^ hi- | C Int -- ^ hi- | D Float -- ^ hi- | E Float Float -- ^ hi--data A = B -- ^ hi continuing the comment- | C Int -- ^ hi- | D Float -- ^ hi- | E Float Float -- ^ hi continuing the comment--a =- case x of- Nothing -> 2- Just something -> 3--a =- case x of- Nothing -> do- putStrLn "hi"- Just something -> 3--a =- case x of- Nothing ->- case y of- 1 -> 2- 3 -> 4- Just something -> 3--a =- case x of- Nothing -> 2- Just x -> 10- Just something -> 3--a =- case x of- Nothing -> 2- Just x -> 10- Just something -> do- putStrLn "hello"--data X =- X- { a :: Int -- ^ hi- , b :: String -- ^ hi- }--data X =- X- { a :: Int -- ^ hi- , b :: String -- ^ hi continued- }
− test/gibiansky/expected/12.exp
@@ -1,93 +0,0 @@-module Main where--module Main where--module Main () where--module Main () where--module Main (main) where--module Main (main, main2) where--module Main (main, main2) where--module Main (main, main2, main3) where--module Main (main, main2, main3, main4) where--module Main (main, main2, main3, main4) where--module Main (- main,- main2,- main3,- main4,- main5,- ) where--module Main (- main,- main2,- main3,- main4,- main5,- ) where--module Main (- main,- main2,- main3,- main4,- main5,- main6,- ) where--module Main (- main,- main2,- main3,- main4,- main5,- main6,- ) where--module Main (- -- * A thing- main,- main2,-- -- * Another thing- main3,- main4,-- -- ** Another thing- main5,- ) where--module Main (- -- * A thing- main,- main2,-- -- * Another thing- main3,- main4,-- -- ** Another thing- main5,- ) where--module Main (main) where->-import Text.Hello--module Main (- main,- main2,- main3,- main4,- main5,- ) where->-import Text.Hello
− test/gibiansky/expected/13.exp
@@ -1,30 +0,0 @@-a = b- where- blah = blah-- -- hello bye- hello = hello--a = b- where- blah = blah-- -- bye- hello = hello--foo = x -- test- where- x = blah--foo = x- where- -- another test- x = blah--f =- case undefined of- Just p- -- If it's the potato.- | zot -> undefined- -- The geriatric concumbine.- | otherwise -> hael
− test/gibiansky/expected/14.exp
@@ -1,10 +0,0 @@-x = \y -> y--(1, 2)--f x = 3-f x = 3--f x- | x == y = 3- | x == y = 3
− test/gibiansky/expected/15.exp
@@ -1,39 +0,0 @@-a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg- veryLongLongLongArg--a = veryLongLongLongName- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = veryLongLongLongName- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--a = veryLongLongLongName- veryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg- veryLongLongLongArg--tests = hello- [ name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- ]--tests = hello goodbye- [ name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- ]
− test/gibiansky/expected/16.exp
@@ -1,3 +0,0 @@-instance A B where- f x = 3- f y = 3
− test/gibiansky/expected/17.exp
@@ -1,3 +0,0 @@-type EventSource a = (AddHandler a, a -> IO ())--type EventSource a = (AddHandler a, a -> IO ())
− test/gibiansky/expected/18.exp
@@ -1,17 +0,0 @@-a = b { c = "d" }--a = b { c = "d", e = "f" }--longLines = longLines- { longLines = "word word word word"- , wordWordWordWord = "long lines long long long"- }--a = B { c = "d" }--a = B { c = "d", e = "f" }--longLines = LongLines- { longLines = "word word word word"- , wordWordWordWord = "long lines long long long"- }
− test/gibiansky/expected/19.exp
@@ -1,18 +0,0 @@-value = value- where- b =- case x of- x -> x- y -> y- a :: b- a = 3--value = value- where- b =- case x of- x -> x- y -> y-- a :: b- a = 3
− test/gibiansky/expected/2.exp
@@ -1,37 +0,0 @@-fun :: a -> b--fun :: a -> f b -> g c d--fun :: Class a => a -> b -> c--fun :: (Class a, Class b) => a -> b -> c--fun :: a- -> b- -> c--fun :: a- -> b- -> c--fun :: a- -> b- -> c--fun :: a- -> b -- ^ Hello- -> c--fun :: a- -> b- -> c -- ^ Hello--fun :: (Class a, Class b)- => a- -> b- -> c -- ^ Hello--fun :: (Class a, Class b)- => a- -> b- -> c -- ^ Hello
− test/gibiansky/expected/20.exp
@@ -1,2 +0,0 @@--- Comment 1 Comment 2-f x = x
− test/gibiansky/expected/21.exp
@@ -1,5 +0,0 @@-a = A- { reallyLongName = reallyLongName- , reallyLongName = reallyLongName- , aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaa- }
− test/gibiansky/expected/22.exp
@@ -1,4 +0,0 @@-a = do- a <- b-- print a
− test/gibiansky/expected/23.exp
@@ -1,11 +0,0 @@-a = b ~.- c--a = b- ~.- c--a = b- ~. c--a = b ~. c
− test/gibiansky/expected/24.exp
@@ -1,19 +0,0 @@-import A->-import B--{-# LANGUAGE FlexibleContexts, OverloadedStrings, RecordWildCards, RankNTypes #-}--blah x- | x = do- putStrLn a--unless x $- unless y $- putStrLn "Hello"--a =- let (x, y) = z- in z--a = (x ++)
− test/gibiansky/expected/25.exp
@@ -1,8 +0,0 @@-main = do- case foo of- Something -> do- x->- Else -> x->- Bar -> x
− test/gibiansky/expected/26.exp
@@ -1,1 +0,0 @@-a +++ b = a * a + b
− test/gibiansky/expected/27.exp
@@ -1,27 +0,0 @@-case x of- -- First- x -> y--case x of- -- First- x -> y->- -- Second- x -> y--case x of- -- First- x -> y->- -- Second- x -> y->- -- Second- x -> y--case x of- -- First- x -> y->- -- Second- x -> y
− test/gibiansky/expected/28.exp
@@ -1,17 +0,0 @@-"ß"---- Test it in pattern context too-"ß" = 3--'ß'--'ß' = 3--"ß"#---- Test it in pattern context too-"ß"# = 3--'ß'#--'ß'# = 3
− test/gibiansky/expected/29.exp
@@ -1,29 +0,0 @@-a =- let x = y- z = 10- in z--a =- let x = y->- z = 10- in z--a =- let x = y->- z = 10->->- z' = 10- in z--a =- let x = y->- -- Comment- z = 10->- -- Comment some more- z' = 10- in z
− test/gibiansky/expected/3.exp
@@ -1,45 +0,0 @@-let x = y- z = w-in x--let x = y- z = w-in x--a =- let x = y- z = w- in x--a =- let x = y- z = w- in x--let x = y- z = w-in x--let z = w-in x--a =- let z = w- in x--a =- let z = w- in x--f x =- let g x = 5- g x = 5- in 3--f =- let y = z- in z--f x =- let y = z- in z
− test/gibiansky/expected/30.exp
@@ -1,22 +0,0 @@--- Hello-a = a---- Hello Hello-a = a---- Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello--- Hello Hello Hello Hello Hello-a = a--{--Hello--}-a = a--type Maybe a = forall r. (a -> r) -> r -> r -- foo bar zot sdfs zot sdfs zot sdfs zot sdfs zot sdfs- -- zot sdfs zot sdfs zot sdfs zot sdfs--type Maybe a = forall r. (a -> r)- -> r- -> r -- foo bar zot sdfs zot sdfs zot sdfs zot sdfs zot sdfs zot sdfs zot sdfs- -- zot sdfs zot sdfs
− test/gibiansky/expected/31.exp
@@ -1,58 +0,0 @@-instance A B->--- Hello-x = y--f x- | pattern <- matched,- condition- = result--f x- | pattern <- matched,- condition- = result--f x- | pattern <- matched,- condition- = result--f x- | pattern <- matched,- pattern2 <- match2,- pattern3 <- match3,- condition- = result--a =- case x of- LongLongRecordConstructor- { longLongLongRecordName = val- , longLongLongRecordName = val- , longLongLongRecordName = val- , longLongLongRecordName = val- , longLongLongRecordName = val- } -> val---- This is a test--- > Should not get rearranged-a = b---- This is a test--- > Should not get rearranged--- > Should not get rearranged-a = b---- This is a test--- >>> Should not get rearranged--- >>> Should not get rearranged-a = b---- This is a test--- @--- f x = 3--- f x = 3--- @----a = b
− test/gibiansky/expected/32.exp
@@ -1,39 +0,0 @@-instance A B where- x = y->-a = b--instance A B where- x = y->-a = b--data ConvertSpec f =- ConvertSpec- { convertToIpynb :: f Bool- , convertInput :: f FilePath- , convertOutput :: f FilePath- , convertLhsStyle :: f (LhsStyle T.Text)- , convertOverwriteFiles :: Bool- }--f b- | b = 3--f b- | b =- 3--a =- case x of- Record { x = x }- | test -> ans--a =- case x of- Just x- | test -> ans--{-# NOINLINE val #-}--{-# INLINE val #-}
− test/gibiansky/expected/33.exp
@@ -1,46 +0,0 @@-f x- | a = b- | a = b- | a = b--f x- | a = b->- | a = b->- | a = b--f x- | a = b->- | a = b->->- | a = b--f x- -- branch- | a = b->- -- branch- | a = b->->- -- branch- | a = b--a = do- let x = y- z = 10- 3--a = do- let x = y->->- z = 10- 3--f x = 3--- test-f x = 3
− test/gibiansky/expected/34.exp
@@ -1,17 +0,0 @@- x = 3--#if- x = 3-#else- y = 3-#endif--f = z + moreThings- where- x = 3-#if MIN_VERSION_ghc(7, 10, 0)- z = 10-#else- z = 11-#endif- moreThings = z + 1
− test/gibiansky/expected/35.exp
@@ -1,3 +0,0 @@- > x = 3- > - > x = 3
− test/gibiansky/expected/36.exp
@@ -1,60 +0,0 @@-import A.Long.Module.Name (With(many, many, many, many, many), imports, and, exports, that,- don't, fit, on, one, line, at, all)--import A.Long.Module.Name (With(many, many, many, many, many),- With(many, many, many, many, many),- With(many, many, many, many, many), imports, and, exports, that,- don't, fit, on, one, line, at, all)--f (Zee x) =- -- Comment!- startswith "No instance for (Show" msg && True--x = do- -- hi- return- output- { longLongLong = 3- , longLongLong = 3- , longLongLong = 3- , longLongLong = 3- , longLongLong = 3- , longLongLong = 3- }--f x = f $ do- -- hello- f x--f x = f $- -- hello- f x--a =- case x of- z -> y -- what- z -> y--class A be where- x = y- z = w--class A b where- x = y->- z = w--data Widget = forall a. IHaskellWidget a => Widget a- deriving Typeable--instance Monoid X where- mempty = X- X `mappend` X = X--a =- let x = X- { y = z- -- FIXME- , z = z- }- in Z
− test/gibiansky/expected/37.exp
@@ -1,5 +0,0 @@-instance A B where- x =- 3->-x = y
− test/gibiansky/expected/38.exp
@@ -1,9 +0,0 @@-type X = Y->--- Comment-instance A a =>- B a where- x = y--{-# INLINE x #-}-x = 3
− test/gibiansky/expected/39.exp
@@ -1,19 +0,0 @@-a =- if | x -> y- | z -> z--a =- if | x- , x <- Just y -> y--a =- f $ \x ->- -- hello- z--a =- f $ \x -> do- -- hello- z--{-# OPTIONS_GHC -option #-}
− test/gibiansky/expected/4.exp
@@ -1,39 +0,0 @@-data A = B--data A = B -- ^ Hello--data A = B -- ^ Hello--data A = B -- ^ Hello--data A = B- | C--data A = B- | C- | D--data A = B- | C- | D--data A = B- | C- | D--data A = B- | C- | D- deriving Show--data A = B- | C- | D- deriving (Show, Eq)--data A = B Int- deriving (Show, Eq)--data A = B Int- | C String- deriving (Show, Eq)
− test/gibiansky/expected/40.exp
@@ -1,3 +0,0 @@-a = b <$> c--a = b <*> d
− test/gibiansky/expected/41.exp
@@ -1,35 +0,0 @@-veryLongExpression = veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong--veryLongExpression = veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong .- veryLong + 3--veryLongExpression = veryLong . veryLong +- veryLong . veryLong +- veryLong . veryLong +- veryLong . veryLong +- veryLong . veryLong +- veryLong . veryLong +- 3--veryLongExpression = veryLong .?! veryLong +?! veryLong .?! veryLong +?! veryLong .?! veryLong +?! veryLong .?! veryLong +?! veryLong .?! veryLong +?! veryLong .?! veryLong +?! 3
− test/gibiansky/expected/42.exp
@@ -1,4 +0,0 @@-f a =- let foo = bar -- retained comment- baz = qux -- the test is to ensure this comment is not dropped- in dog
− test/gibiansky/expected/43.exp
@@ -1,8 +0,0 @@-test x- | x == 0 = 0- | otherwise =- let foo y- | y == 0 = 0 -- comment one- | y == 0 = 1 -- comment two- | otherwise = 2 -- comment three- in bar x
− test/gibiansky/expected/44.exp
@@ -1,3 +0,0 @@-test foo bar [] = baz qux --comment zero-test foo bar [x] = baz qux --comment one-test foo bar [x:xs] = baz qux --comment two
− test/gibiansky/expected/45.exp
@@ -1,2 +0,0 @@-a :: forall b. Typeable b => b-a = 3
− test/gibiansky/expected/46.exp
@@ -1,7 +0,0 @@-type X = '[]--type X = '[Int]--type X = '[Int, String]--a :: (A ∈ B w) => IO w
− test/gibiansky/expected/5.exp
@@ -1,30 +0,0 @@-data A = B { field :: Int }--data A = B { field :: Int, field2 :: Char }--data A = B { field :: Int, field2 :: Char, field3 :: String }--data A = B { field :: Int, field2 :: Char, field3 :: String }- deriving Show--data A = B { field :: Int, field2 :: Char, field3 :: String }- deriving Show--data A = B { field :: Int, field2 :: Char, field3 :: String }- deriving (Show, Eq)--data A = B { field :: Int, field2 :: Char, field3 :: String }- deriving (Show, Eq)--data A =- B- { field :: Int -- ^ Field 1- }--data A =- B- { field :: Int -- ^ Field 1- , field2 :: Char -- ^ field 2- , field3 :: String- }- deriving Show
− test/gibiansky/expected/6.exp
@@ -1,48 +0,0 @@-a =- case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a =- case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a =- case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a =- case f x of- Nothing -> 1- Just x -> 3--a =- case f x of- Nothing -> 1- Just x -> 3--a =- case f x of- Nothing -> 1- Just x -> 3--a =- case f x of- Nothing -> do- return 3- Just x -> return ()--a =- case f x of- Nothing -> do- return 3- Just x -> do- return 5
− test/gibiansky/expected/7.exp
@@ -1,34 +0,0 @@-a = b- where- value = 3- value' = 5--a = b- where- value = 3- value' = 5--a = b- where- value = 3- value' = 5--a =- b- where- value = 3- value' = 5--a = do- return ()-- where- value = 3- value' = 5--a = do- return ()-- where- value = 3- value' = 5
− test/gibiansky/expected/8.exp
@@ -1,29 +0,0 @@-a = [1, 2, 3]--a = [1, 2, 3]--a = [1, 2, 3]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing- ]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing- ]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing- ]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing- ]
− test/gibiansky/expected/9.exp
@@ -1,20 +0,0 @@-import Data.Attoparsec.ByteString-import Data.Attoparsec.Expr-import Data.ByteString (split)--import Data.Attoparsec.ByteString-import qualified Data.Attoparsec.Expr as X-import Data.ByteString (split)--main :: IO ()-main = return ()--main :: IO ()-main =- return ()--main :: a- -> b- -> c-main =- return ()
− test/gibiansky/tests/1.test
@@ -1,11 +0,0 @@-import Data.Text--import Data.Text--import qualified Data.Text as T--import qualified Data.Text (a, b, c)--import Data.Text (a, b, c)--import Data.Text hiding (a, b, c)
− test/gibiansky/tests/10.test
@@ -1,41 +0,0 @@-unless hello $- case thing of- Left a -> 3- Right b -> 5--when hello $- case thing of- Left a -> 3- Right b -> 5--a = \line ->- case a of- Left a -> a- Right b -> b--map (\x -> x) [1, 2, 3]--forM_ lst $ \x -> do- putStrLn x--forM_ lst $ \x ->- putStrLn x--Value <$> thing <*> secondThing--Value <$> thing <*> secondThing <*> thirdThing <*> fourthThing <*> Just thisissolong <*> Just stilllonger--f e = 5- where- a = b--a = b- where- c = d- e = f--a = b- where- c = d-- e = f
− test/gibiansky/tests/11.test
@@ -1,43 +0,0 @@-data A = B -- ^ hi- | C Int -- ^ hi- | D Float -- ^ hi- | E Float Float -- ^ hi--data A = B -- ^ hi continuing the comment- | C Int -- ^ hi- | D Float -- ^ hi- | E Float Float -- ^ hi continuing the comment--a = case x of- Nothing -> 2- Just something -> 3--a = case x of- Nothing -> do- putStrLn "hi"- Just something -> 3--a = case x of- Nothing -> case y of- 1 -> 2- 3 -> 4- Just something -> 3--a = case x of- Nothing -> 2- Just x -> 10- Just something -> 3--a = case x of- Nothing -> 2- Just x -> 10- Just something -> do- putStrLn "hello"--data X = X { a :: Int -- ^ hi- , b :: String -- ^ hi- }--data X = X { a :: Int -- ^ hi- , b :: String -- ^ hi continued- }
− test/gibiansky/tests/12.test
@@ -1,86 +0,0 @@-module Main where--module Main- where--module Main () where--module Main (- ) where--module Main (main) where--module Main (main, main2) where--module Main (main,- main2) where--module Main (main, main2, main3) where--module Main (main, main2, main3, main4) where--module Main (main,- main2, main3,- main4) where--module Main (- main,- main2,- main3,- main4,- main5,- ) where--module Main ( main, main2, main3, main4,- main5,- ) where--module Main (- main,- main2,- main3,- main4,- main5,- main6,- ) where--module Main (- main, main2, main3, main4, main5, main6,- ) where--module Main (- -- * A thing- main,- main2,-- -- * Another thing- main3,- main4,-- -- ** Another thing- main5,- ) where--module Main (- -- * A thing- main, main2,-- -- * Another thing- main3, main4,-- -- ** Another thing- main5,) where--module Main (main) where->-import Text.Hello--module Main (- main,- main2,- main3,- main4,- main5,- ) where->-import Text.Hello
− test/gibiansky/tests/13.test
@@ -1,28 +0,0 @@-a = b- where- blah = blah-- -- hello bye- hello = hello--a = b- where- blah = blah-- -- bye- hello = hello--foo = x -- test- where- x = blah--foo = x- where -- another test- x = blah--f = case undefined of- Just p- -- If it's the potato.- | zot -> undefined- -- The geriatric concumbine.- | otherwise -> hael
− test/gibiansky/tests/14.test
@@ -1,10 +0,0 @@-x = \y -> y--(1, 2)--f x = 3-f x = 3--f x- | x == y = 3- | x == y = 3
− test/gibiansky/tests/15.test
@@ -1,21 +0,0 @@-a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--a = veryLongLongLongName veryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg veryLongLongLongArg--tests = hello- [ name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- ]--tests = hello goodbye- [ name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- , name "space space space space space space space space space space space" thing- ]
− test/gibiansky/tests/16.test
@@ -1,3 +0,0 @@-instance A B where- f x = 3- f y = 3
− test/gibiansky/tests/17.test
@@ -1,4 +0,0 @@-type EventSource a = (AddHandler a, a -> IO ())--type EventSource a = (AddHandler a,- a -> IO ())
− test/gibiansky/tests/18.test
@@ -1,11 +0,0 @@-a = b { c = "d" }--a = b { c = "d", e = "f" }--longLines = longLines { longLines = "word word word word", wordWordWordWord = "long lines long long long" }--a = B { c = "d" }--a = B { c = "d", e = "f" }--longLines = LongLines { longLines = "word word word word", wordWordWordWord = "long lines long long long" }
− test/gibiansky/tests/19.test
@@ -1,16 +0,0 @@-value = value- where- b = case x of- x -> x- y -> y- a :: b- a = 3--value = value- where- b = case x of- x -> x- y -> y-- a :: b- a = 3
− test/gibiansky/tests/2.test
@@ -1,32 +0,0 @@-fun :: a -> b--fun :: a -> f b -> g c d--fun :: Class a => a -> b -> c--fun :: (Class a, Class b) => a -> b -> c--fun :: a- -> b- -> c--fun :: a- -> b- -> c--fun :: a- -> b- -> c--fun :: a -> b -- ^ Hello- -> c--fun :: a -> b- -> c -- ^ Hello--fun :: (Class a, Class b) => a -> b- -> c -- ^ Hello--fun :: (Class a, Class b) =>- a -> b- -> c -- ^ Hello
− test/gibiansky/tests/20.test
@@ -1,2 +0,0 @@--- Comment 1 Comment 2-f x = x
− test/gibiansky/tests/21.test
@@ -1,5 +0,0 @@-a = A- { reallyLongName = reallyLongName- , reallyLongName = reallyLongName- , aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaa- }
− test/gibiansky/tests/22.test
@@ -1,4 +0,0 @@-a = do- a <- b-- print a
− test/gibiansky/tests/23.test
@@ -1,11 +0,0 @@-a = b ~.- c--a = b- ~.- c--a = b- ~. c--a = b ~. c
− test/gibiansky/tests/24.test
@@ -1,18 +0,0 @@-import A->-import B--{-# LANGUAGE FlexibleContexts, OverloadedStrings, RecordWildCards, RankNTypes #-}->--blah x- | x = do- putStrLn a--unless x $- unless y $- putStrLn "Hello"--a = let (x, y) = z in z--a = (x ++)
− test/gibiansky/tests/25.test
@@ -1,8 +0,0 @@-main = do- case foo of- Something -> do- x->- Else -> x->- Bar -> x
− test/gibiansky/tests/26.test
@@ -1,1 +0,0 @@-a +++ b = a * a + b
− test/gibiansky/tests/27.test
@@ -1,28 +0,0 @@-case x of- -- First- x -> y--case x of- -- First- x -> y->- -- Second- x -> y--case x of- -- First- x -> y->- -- Second- x -> y->- -- Second- x -> y--case x of- -- First- x -> y->- -- Second->- x -> y
− test/gibiansky/tests/28.test
@@ -1,17 +0,0 @@-"ß"---- Test it in pattern context too-"ß" = 3--'ß'--'ß' = 3--"ß"#---- Test it in pattern context too-"ß"# = 3--'ß'#--'ß'# = 3
− test/gibiansky/tests/29.test
@@ -1,29 +0,0 @@-a =- let x = y- z = 10- in z--a =- let x = y->- z = 10- in z--a =- let x = y->- z = 10->->- z' = 10- in z--a =- let x = y->- -- Comment- z = 10->- -- Comment some more- z' = 10- in z
− test/gibiansky/tests/3.test
@@ -1,38 +0,0 @@-let x = y- z = w in x--let x = y- z = w- in x--a = let x = y- z = w- in x--a = let- x = y- z = w- in x--let- x = y- z = w in x--let- z = w in x--a = let- z = w- in x--a = let z = w- in x--f x =- let g x = 5- g x = 5- in 3--f = let y = z in z--f x = let y = z in z
− test/gibiansky/tests/30.test
@@ -1,25 +0,0 @@--- Hello-a = a---- Hello--- Hello-a = a---- Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello-a = a--{--Hello--}-a = a--type Maybe a = forall r. (a -> r) -> r -> r -- foo bar zot sdfs zot- -- sdfs zot sdfs zot sdfs- -- zot sdfs zot sdfs zot- -- sdfs zot sdfs zot sdfs--type Maybe a = - forall r. (a -> r) - -> r - -> r -- foo bar zot sdfs zot sdfs zot sdfs zot sdfs zot- -- sdfs zot sdfs zot sdfs zot sdfs zot sdfs
− test/gibiansky/tests/31.test
@@ -1,48 +0,0 @@-instance A B->--- Hello-x = y--f x- | pattern <- matched,- condition- = result--f x- | pattern <- matched, condition- = result--f x- | pattern <- matched, condition = result--f x- | pattern <- matched,- pattern2 <- match2,- pattern3 <- match3,- condition- = result--a = case x of- LongLongRecordConstructor { longLongLongRecordName = val, longLongLongRecordName = val, longLongLongRecordName = val, longLongLongRecordName = val, longLongLongRecordName = val } -> val---- This is a test--- > Should not get rearranged-a = b---- This is a test--- > Should not get rearranged--- > Should not get rearranged-a = b---- This is a test--- >>> Should not get rearranged--- >>> Should not get rearranged-a = b---- This is a test--- @--- f x = 3--- f x = 3--- @----a = b
− test/gibiansky/tests/32.test
@@ -1,37 +0,0 @@-instance A B where- x = y->-a = b--instance A B where- x = y->-a = b--data ConvertSpec f =- ConvertSpec- { convertToIpynb :: f Bool- , convertInput :: f FilePath- , convertOutput :: f FilePath- , convertLhsStyle :: f (LhsStyle T.Text)- , convertOverwriteFiles :: Bool- }--f b- | b = 3--f b- | b =- 3--a =- case x of- Record { x = x }| test -> ans--a =- case x of- Just x | test -> ans--{-# NOINLINE val #-}--{-# INLINE val #-}
− test/gibiansky/tests/33.test
@@ -1,46 +0,0 @@-f x- | a = b- | a = b- | a = b--f x- | a = b->- | a = b->- | a = b--f x- | a = b->- | a = b->->- | a = b--f x- -- branch- | a = b->- -- branch- | a = b->->- -- branch- | a = b--a = do- let x = y- z = 10- 3--a = do- let x = y->->- z = 10- 3--f x = 3--- test-f x = 3
− test/gibiansky/tests/34.test
@@ -1,17 +0,0 @@- x = 3--#if- x = 3-#else- y = 3-#endif--f = z + moreThings- where- x = 3-#if MIN_VERSION_ghc(7, 10, 0)- z = 10-#else- z = 11-#endif- moreThings = z + 1
− test/gibiansky/tests/35.test
@@ -1,2 +0,0 @@- > x = 3- > x = 3
− test/gibiansky/tests/36.test
@@ -1,46 +0,0 @@-import A.Long.Module.Name (With(many, many, many, many, many), imports, and, exports, that, don't, fit, on, one, line, at, all)--import A.Long.Module.Name (With(many, many, many, many, many), With(many, many, many, many, many), With(many, many, many, many, many), imports, and, exports, that, don't, fit, on, one, line, at, all)--f (Zee x) =- -- Comment!- startswith "No instance for (Show" msg && True--x = do- -- hi- return output { longLongLong = 3, longLongLong = 3, longLongLong = 3, longLongLong = 3, longLongLong = 3, longLongLong = 3}--f x = f $ do- -- hello- f x--f x = f $- -- hello- f x--a =- case x of- z -> y -- what- z -> y--class A be where- x = y- z = w--class A b where- x = y->- z = w--data Widget = forall a. IHaskellWidget a => Widget a- deriving Typeable--instance Monoid X where- mempty = X- X `mappend` X = X--a =- let x = X { y = z, - -- FIXME- z = z }- in Z
− test/gibiansky/tests/37.test
@@ -1,5 +0,0 @@-instance A B where- x =- 3->-x = y
− test/gibiansky/tests/38.test
@@ -1,9 +0,0 @@-type X = Y->--- Comment-instance A a => B a where- x = y->--{-# INLINE x #-}-x = 3
− test/gibiansky/tests/39.test
@@ -1,19 +0,0 @@-a = - if | x -> y- | z -> z--a =- if | x, x <- Just y -> y--a =- f $ \x ->- -- hello- z--a =- f $ \x -> do- -- hello- z--{-# OPTIONS_GHC -option #-}->
− test/gibiansky/tests/4.test
@@ -1,36 +0,0 @@-data A = B--data A = B -- ^ Hello--data A = - B -- ^ Hello--data A- = B -- ^ Hello--data A = B | C--data A = B | C | D--data A = B | C - | D--data A = B - | C - | D--data A = B - | C - | D- deriving Show--data A = B - | C - | D- deriving (Show, Eq)--data A = B Int- deriving (Show, Eq)--data A = B Int | C String- deriving (Show, Eq)
− test/gibiansky/tests/40.test
@@ -1,3 +0,0 @@-a = b <$> c--a = b <*> d
− test/gibiansky/tests/41.test
@@ -1,7 +0,0 @@-veryLongExpression = veryLong . veryLong . veryLong .veryLong . veryLong . veryLong .veryLong . veryLong . veryLong .veryLong . veryLong . veryLong--veryLongExpression = veryLong . veryLong . veryLong .veryLong . veryLong . veryLong .veryLong . veryLong . veryLong .veryLong . veryLong . veryLong + 3--veryLongExpression = veryLong . veryLong + veryLong .veryLong + veryLong . veryLong +veryLong . veryLong + veryLong .veryLong + veryLong . veryLong + 3--veryLongExpression = veryLong .?! veryLong +?! veryLong .?!veryLong +?! veryLong .?! veryLong +?!veryLong .?! veryLong +?! veryLong .?!veryLong +?! veryLong .?! veryLong +?! 3
− test/gibiansky/tests/42.test
@@ -1,4 +0,0 @@-f a =- let foo = bar -- retained comment- baz = qux -- the test is to ensure this comment is not dropped- in dog
− test/gibiansky/tests/43.test
@@ -1,7 +0,0 @@-test x- | x == 0 = 0- | otherwise = let foo y- | y == 0 = 0 -- comment one- | y == 0 = 1 -- comment two- | otherwise = 2 -- comment three- in bar x
− test/gibiansky/tests/44.test
@@ -1,3 +0,0 @@-test foo bar [] = baz qux --comment zero-test foo bar [x] = baz qux --comment one-test foo bar [x:xs] = baz qux --comment two
− test/gibiansky/tests/45.test
@@ -1,2 +0,0 @@-a :: forall b. Typeable b => b-a = 3
− test/gibiansky/tests/46.test
@@ -1,7 +0,0 @@-type X = '[]--type X = '[Int]--type X = '[Int, String]--a :: (A ∈ B w) => IO w
− test/gibiansky/tests/5.test
@@ -1,27 +0,0 @@-data A = B { field :: Int }--data A = B { field :: Int, field2 :: Char }--data A = B { field :: Int, field2 :: Char, field3 :: String }--data A = B { field :: Int,- field2 :: Char, field3 :: String } deriving Show--data A = B { field :: Int,- field2 :: Char,- field3 :: String } deriving Show--data A = B { field :: Int- , field2 :: Char- , field3 :: String } deriving (Show, Eq)--data A = B { field :: Int- , field2 :: Char- , field3 :: String } deriving (Show, Eq)--data A = B { field :: Int -- ^ Field 1- }--data A = B { field :: Int, -- ^ Field 1- field2 :: Char, -- ^ field 2- field3 :: String } deriving Show
− test/gibiansky/tests/6.test
@@ -1,41 +0,0 @@-a = case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case - f x of- 1 -> 1- 2 -> 3- 3 -> 4- _ -> 100--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> 1- Just x -> 3--a = case f x of- Nothing -> do- return 3- Just x -> return ()--a = case f x of- Nothing -> do- return 3- Just x -> do- return 5
− test/gibiansky/tests/7.test
@@ -1,30 +0,0 @@-a = b- where- value = 3- value' = 5--a = b where- value = 3- value' = 5--a = b- where value = 3- value' = 5--a =- b where- value = 3- value' = 5--a = do- return ()-- where- value = 3- value' = 5--a = do- return ()- where- value = 3- value' = 5
− test/gibiansky/tests/8.test
@@ -1,24 +0,0 @@-a = [1, 2, 3]--a = [1, 2- , 3]--a = [ 1- , 2- , 3]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing- ]--a = [Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine, Nothing]--a = [ Just theRightAnswerWithAVeryLongLine, Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine, Nothing]--a = [ Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Just theRightAnswerWithAVeryLongLine- , Nothing]
− test/gibiansky/tests/9.test
@@ -1,19 +0,0 @@-import Data.Attoparsec.ByteString-import Data.Attoparsec.Expr-import Data.ByteString (split)--import Data.Attoparsec.ByteString-import qualified Data.Attoparsec.Expr as X-import Data.ByteString (split)--main :: IO ()-main = return ()--main :: IO ()-main =- return ()--main :: a -> b- -> c-main =- return ()