I could not see an existing option to allow the popular style of formatting where the in expression is aligned with the let bindings, for example (taken from Learn You a Haskell for Great Good!):
cylinder :: (RealFloat a) => a -> a -> a
cylinder r h =
let sideArea = 2 * pi * r * h
topArea = pi * r ^2
in sideArea + 2 * topArea
If there is not an existing option, I think this can be achieved by adding an option to OptionConfig (say cfgOptionAlignLetBindsAndInExpr :: !Bool) and then modifying the relevant part of prettyPrint to be:
prettyPrint (Let _ binds expr) = withLayout cfgLayoutLet flex vertical
where
flex = do
write "let "
prettyOnside (CompactBinds binds)
spaceOrNewline
nl <- gets psNewline
alignP <- getOption cfgOptionAlignLetBindsAndInExpr
write $ if nl && alignP then "in " else "in "
prettyOnside expr
vertical = withIndentAfter
cfgIndentLet
(do
write "let"
withIndent cfgIndentLetBinds $
pretty (CompactBinds binds))
(do
newline
alignP <- getOption cfgOptionAlignLetBindsAndInExpr
write $ if alignP then "in " else "in"
withIndent cfgIndentLetIn $ pretty expr)
If that is of interest, I can propose a pull request.
I could not see an existing option to allow the popular style of formatting where the
in
expression is aligned with thelet
bindings, for example (taken from Learn You a Haskell for Great Good!):If there is not an existing option, I think this can be achieved by adding an option to
OptionConfig
(saycfgOptionAlignLetBindsAndInExpr :: !Bool
) and then modifying the relevant part ofprettyPrint
to be:If that is of interest, I can propose a pull request.