Update Showcase.md: Add hindent johan-tibell style

pull/3/head
Lennart Spitzner 2016-08-12 16:03:41 +02:00 committed by GitHub
parent 1f00f9ac61
commit a99869690c
1 changed files with 92 additions and 4 deletions

View File

@ -62,7 +62,7 @@ layoutBriDoc ast briDoc = do
return $ () return $ ()
~~~~ ~~~~
## brittany output ## `brittany` output
~~~~ .hs ~~~~ .hs
-- 10 20 30 40 50 60 70 80 -- 10 20 30 40 50 60 70 80
@ -140,9 +140,97 @@ layoutBriDoc ast briDoc = do
return $ () return $ ()
~~~~ ~~~~
In contrast, let us look at Chris Done's `hindent` (version `4.6.4`) re-formatting results for the same input, with two different styles: In contrast, let us look at Chris Done's `hindent` (version `4.6.4`) re-formatting results for the same input, with three different styles:
## hindent --style chris-done output ## `hindent --style johan-tibell` output
~~~~ .hs
-- 10 20 30 40 50 60 70 80
module Language.Haskell.Brittany.BriLayouter
(layoutBriDoc)
where
layoutBriDoc
:: Data.Data.Data ast
=> ast -> BriDocNumbered -> PPM ()
layoutBriDoc ast briDoc = do
-- first step: transform the briDoc.
briDoc' <-
MultiRWSS.withMultiStateS BDEmpty $
do traceIfDumpConf "bridoc raw" _dconf_dump_bridoc_raw $
briDocToDoc $ unwrapBriDocNumbered $ briDoc
-- bridoc transformation: remove alts
transformAlts
briDoc >>=
mSet
mGet >>=
traceIfDumpConf "bridoc post-alt" _dconf_dump_bridoc_simpl_alt .
briDocToDoc
-- bridoc transformation: float stuff in
mGet <&>
transformSimplifyFloating >>=
mSet
mGet >>=
traceIfDumpConf
"bridoc post-floating"
_dconf_dump_bridoc_simpl_floating .
briDocToDoc
-- bridoc transformation: par removal
mGet <&>
transformSimplifyPar >>=
mSet
mGet >>=
traceIfDumpConf "bridoc post-par" _dconf_dump_bridoc_simpl_par .
briDocToDoc
-- bridoc transformation: float stuff in
mGet <&>
transformSimplifyColumns >>=
mSet
mGet >>=
traceIfDumpConf
"bridoc post-columns"
_dconf_dump_bridoc_simpl_columns .
briDocToDoc
-- -- bridoc transformation: indent
mGet <&>
transformSimplifyIndent >>=
mSet
mGet >>=
traceIfDumpConf
"bridoc post-indent"
_dconf_dump_bridoc_simpl_indent .
briDocToDoc
mGet >>=
traceIfDumpConf "bridoc final" _dconf_dump_bridoc_final .
briDocToDoc
-- -- convert to Simple type
-- simpl <- mGet <&> transformToSimple
-- return simpl
anns :: ExactPrint.Types.Anns <- mAsk
let filteredAnns = filterAnns ast anns
let state =
LayoutState
{ _lstate_baseY = 0
, _lstate_curY = 0
, _lstate_indLevel = 0
, _lstate_indLevelLinger = 0
, _lstate_commentsPrior = extractCommentsPrior filteredAnns
, _lstate_commentsPost = extractCommentsPost filteredAnns
, _lstate_commentCol = Nothing
, _lstate_addSepSpace = Nothing
, _lstate_inhibitMTEL = False
, _lstate_isNewline = NewLineStateInit
}
state' <- MultiRWSS.withMultiStateS state $ layoutBriDocM briDoc'
let remainingComments =
Map.elems (_lstate_commentsPrior state') ++
Map.elems (_lstate_commentsPost state')
remainingComments `forM_`
(mTell . (: []) . LayoutErrorUnusedComment . show . fmap fst)
return $ ()
~~~~
## `hindent --style chris-done` output
~~~~ .hs ~~~~ .hs
-- 10 20 30 40 50 60 70 80 -- 10 20 30 40 50 60 70 80
@ -222,7 +310,7 @@ layoutBriDoc ast briDoc =
return $ () return $ ()
~~~~ ~~~~
## hindent --style gibiansky output ## `hindent --style gibiansky` output
note that it managed to garbage the first comment to `-- 10 20 30 40 50 60 70 80` which i replaced again afterwards. note that it managed to garbage the first comment to `-- 10 20 30 40 50 60 70 80` which i replaced again afterwards.