Commit Graph

286 Commits (b95bc09a9d9b07b5b3dbfb6eff7ddd9d50f38b82)

Author SHA1 Message Date
Lennart Spitzner b1c6be7acd Fix parentheses around kind signatures, fixes #64 2017-10-15 00:23:14 +02:00
Lennart Spitzner f86665a251 Fix promoted HsTyVars on ghc-8.2.1
This fix does not work on ghc-8.0, because I do not understand
the 8.0 API in this instance. Could be resolved by looking
at annotations, but that really should not be necessary.
2017-10-14 23:21:13 +02:00
Lennart Spitzner ccf2eb092f Support RecordWildCards, Add one-liner layouting for records
fixes #52
2017-10-01 17:24:13 +02:00
Lennart Spitzner a348ae7fbc Switch to XDG path for config; Search conf in parents
- switch to XDG path should be backwards-compatible:
  - new config will be written to XDG path
  - but existing config in ~/.brittany will be respected
- looks for "brittany.yaml" not only in cwd, but in parents too.
  uses the first file found.

fixes #45, fixes #55
2017-09-29 21:42:39 +02:00
Lennart Spitzner d1606932f8 Minor cleanup / performance improvement 2017-09-20 23:35:45 +02:00
Lennart Spitzner 867016c198 Fix quadratic behaviour (fixes #34)
Split up annotations by top-level elements in one
go, instead of doing the filtering per top-level
element (which necessarily makes things quadratic,
or rather O(n*m) with n top-level elements and m
size of annotation map). The fixed version should
be O(log n * m), and log n is negligible.
2017-09-20 23:35:45 +02:00
Lennart Spitzner 9703ebead5 Fix #53
Previously, if the input did not end with a newline
character and config had 'ppconf_hackAroundIncludes = True'
then due to using unlines/lines the output contained an
additional newline.
2017-09-10 16:37:35 +02:00
Lennart Spitzner ca13a1897f Fix type application layouting (fixes #48)
- one-line externals are not detected as multiline in backend
- layouting of EAsPat (when TypeApplications is disabled)
- layouting of HsTyLit (TypeApplications with literals)
2017-08-20 14:09:03 +02:00
Lennart Spitzner fba8ad1a99 Fix negative literals in patterns (fixes #49) 2017-08-20 00:34:13 +02:00
Lennart Spitzner 1288c37204 Disable specific optim. in Config/Types/Instances 2017-08-19 14:56:46 +02:00
Lennart Spitzner aba7d13f67 Fix stupid haddock needs 2017-08-16 00:14:56 +02:00
Lennart Spitzner 6f4eec245e Split up Config/Types.hs
for the compilation of that module, GHC max residency
was an astounding 600MB for Config/Types.hs;
for Config/Types/Instances.hs it now "only" is 480MB.
(numbers according to "+RTS -s", the real usage
accoding to `time` is about 20% higher even.)
2017-08-15 20:37:46 +02:00
Lennart Spitzner 3ac8cccb0f Refactor prelude.inc/Prelude to reduce imports 2017-08-12 23:51:07 +02:00
Lennart Spitzner ebf84a03e9 Merge remote-tracking branch 'origin/master' 2017-08-12 15:29:06 +02:00
Erik Schnetter 0774d0e413 Correct typographical errors in comments 2017-08-11 21:37:29 -04:00
Lennart Spitzner 655074d1c0 Fix comment insertion error introduced in 91b9a240 2017-08-10 13:09:39 +02:00
Lennart Spitzner 91b9a240f1 Fix comment-before-BDCols issue; Relax alignmentBreakOnMultiline 2017-08-07 00:35:09 +02:00
Lennart Spitzner 41beeb9723 Remove/Cleanup unused/deprecated MTEL stuff 2017-08-06 16:28:41 +02:00
Lennart Spitzner b39997fcfa Adapt for ghc-8.2
Could it be so simple?
2017-08-05 18:17:49 +02:00
Lennart Spitzner ccb59ef803 Fix wherespecial with indent/=2 (fixes #39) 2017-08-05 16:09:46 +02:00
Lennart Spitzner 00ad6c71b9 Impl. layouting of TypeApplication, fixes #38 2017-07-28 18:03:21 +02:00
Alan Zimmerman 33eed86851 Fix haddock generation.
Otherwise the haddock process complains about malformed haddock comments
2017-07-07 10:40:55 +02:00
Lennart Spitzner 134f31e4d1 Add Semigroup instances for C*Config Identity 2017-07-05 00:08:21 +02:00
Lennart Spitzner 6268b8075a Fix layouting bug for RecordUpd 2017-07-04 23:57:54 +02:00
Lennart Spitzner 5a82968a7b Add sub-config-alternative default to lib interface
i.e. `forwardOptionsSyntaxExtsEnabled`
2017-07-04 23:26:13 +02:00
Lennart Spitzner 0251062100 Support mdo layouting (RecursiveDo) 2017-06-29 18:13:28 +02:00
Lennart Spitzner cece70380c Fix/Implement proper layouting of MultiWayIf 2017-06-28 23:35:02 +02:00
Lennart Spitzner 6d472315e3 Fix layouting special-case (getSpacing(s) internals) 2017-06-04 18:15:22 +02:00
Lennart Spitzner 5e3cc0a7c3 Fix OpApp layouting/indentation annoyance 2017-06-04 16:28:01 +02:00
Lennart Spitzner 16f5aa118d Add flag to omit reformatting (ghc-exactprint only) 2017-06-03 21:01:24 +02:00
Lennart Spitzner 9f4cda9130 Add license (AGPLv3) 2017-06-03 18:23:03 +02:00
Lennart Spitzner 91429ccacc Remove unordered-containers direct dependency 2017-06-03 18:23:03 +02:00
Lennart Spitzner 3784a0123b Refactor exposed function (now parsePrintModule)
- Rename parsePrintModule -> parsePrintModuleTests
- Rename pureModuleTransform -> parsePrintModule
- Change argument type from (CConfig Option) to Config
- Expose CConfig type fully
2017-06-03 18:23:03 +02:00
Lennart Spitzner dfec26e55b Refactor/Rename LayoutError -> BrittanyError 2017-06-03 18:23:03 +02:00
Lennart Spitzner 1adf02dabe Add instance Monoid (CConfig Option) 2017-06-03 18:23:03 +02:00
Lennart Spitzner f350113f7f Refactor all modules: +Internal; Add public Brittany module 2017-05-22 21:25:08 +02:00
Lennart Spitzner 5dbe0f2c9c Add function pureModuleTransform 2017-05-22 21:06:02 +02:00
Lennart Spitzner fd9427754e Add "hackAroundIncludes" option (default false)
- Makes brittany work in stdin/stdout mode when
  CPP usage is limited to #includes.
2017-05-22 15:49:18 +02:00
Lennart Spitzner 3957272c10 Improve backwards-compat for config (manual FromJson) 2017-05-22 15:45:14 +02:00
Lennart Spitzner 8f1e366f9c Change config file structure; Add config version tag 2017-05-21 16:48:05 +02:00
Lennart Spitzner 4ee44388f7 Improve layouting for OpApp (special-case for dollar/HsVar) 2017-05-21 13:43:39 +02:00
Lennart Spitzner b8396da1d6 Refactor Backend.hs (Move stuff to top-level) 2017-05-21 13:17:46 +02:00
Lennart Spitzner 8b7b1334e2 Fix forall type signature layouting 2017-05-18 14:18:10 +02:00
Lennart Spitzner 83ba7803e6 Fix layouting issues in lists/listcomprehension 2017-05-17 23:31:20 +02:00
Lennart Spitzner 56e53a9cbb Apply brittany to `layoutBriDocM` 2017-05-17 21:41:07 +02:00
Lennart Spitzner 6448ee780a Restrict aggressive horizontal alignment (fixes #21)
- Add config values:
  _lconfig_alignmentLimit for roughly "max spaces inserted"
  _lconfig_alignmentBreakOnMultiline for stopping
  alignment after non-singleline-items
2017-05-17 21:34:49 +02:00
Lennart Spitzner 22300d9c62 Minor cleanups 2017-05-14 17:10:20 +02:00
Lennart Spitzner 41a86b2eab Use czipwith package (replacing CZip), Refactor slightly 2017-05-14 17:04:58 +02:00
Lennart Spitzner 4770dbdb7c Remove lens dependency (was not used) 2017-05-14 12:05:19 +02:00
Lennart Spitzner c701e5d00b Fix #26: Fix comment glitch in patternbind layouting
Prevent single-line layout when it would not even be
a single line due to a comment.
This patch might be a bit over-eager in at least one
case (I think you'd get a two-line layout with a
multiway-if and a comment _after_ the where binding).
2017-05-02 17:10:04 +02:00
Lennart Spitzner c3dc3b6074 And one more touch to ExplicitList 2017-05-02 16:32:43 +02:00
Lennart Spitzner ca42178eff Improve tuple layouting (also fixes #18 for tuples) 2017-05-02 16:21:13 +02:00
Lennart Spitzner f6324da600 Fix ExplicitList comment insertion (fixes #18) 2017-05-02 14:20:58 +02:00
Lennart Spitzner 26ffb40fb4 Fixup for config file generation
- fixes a silent bug; behaviour seems not to be affected.
2017-04-16 13:55:49 +02:00
Lennart Spitzner cbeab39b2d Fix comment/eof space handling (fixes #22) 2017-04-15 14:50:55 +02:00
Lennart Spitzner 505ad99f35 Handle InlineSig construct (pragma), fixes #20 2017-04-12 21:47:59 +02:00
Lennart Spitzner acbaba0782 Omit output syntax test for fix-point tests 2017-04-12 14:53:47 +02:00
Lennart Spitzner 14884be8df Minor fixups in docs plus some minor Refactoring 2017-04-12 14:31:53 +02:00
Lennart Spitzner 2dd6fe83f5 Add documentation and examples; Add debugging flag; Minor refactors 2017-03-30 22:47:00 +02:00
Lennart Spitzner 2b30d83fe8 Fix CPP/macro usage for MacOS; Fix minor stuff in .cabal 2017-03-27 16:18:14 +02:00
Lennart Spitzner a7e4bdc168 Fix #16; Improve layouting in two cases; Add comments
- the #16 fix is a one-liner:
  Throw `nub` at spacings before pruning.
- Expr/OpApp layouting: Force single-line for children in
  the params-in-multiple-lines-right-of-the-function case.
- Expr/HsIf layouting: Insert a SetBaseY to prevent
  "then"/"else" being placed left of "if".
2017-03-16 23:02:11 +01:00
Lennart Spitzner 109163fc4d Remove traceShow statement
fixes #15
2017-03-08 14:55:02 +01:00
Lennart Spitzner 7dc6c525eb Fix minor layouting issue with long guards
(see test multiple-clauses-4)
2017-03-07 21:44:28 +01:00
Lennart Spitzner 00c7384d20 Fix config printing (config file generation) 2017-03-07 21:14:41 +01:00
Lennart Spitzner cea81d5369 Add indentation to the paragraphs inserted in patterns
Ugly, but fixes #6. Ugly still better than non-valid-haskell result.
2017-03-06 16:56:38 +01:00
Lennart Spitzner 8d163eb099 Improve layouting for equations with multiple clauses
e.g.
func x | x         = simple expression
       | otherwise = 0

This fixes part of #7
2017-03-06 16:03:47 +01:00
Lennart Spitzner df422ffa5f Refactor/Cleanup layoutPatternBindFinal 2017-03-06 15:55:12 +01:00
Lennart Spitzner 575d530188 Use ExactPrintFallback for unknown constructs
fixes #11
2017-03-06 12:45:19 +01:00
Lennart Spitzner bc70eb07e8 Change config setup(!), Refactor, Update deps
- config now uses foo_bar instead of _foo_bar;
- config now will accept missing keys;
- use latest butcher version;
- improve identity testing by moving into separate file.
2017-01-31 18:43:16 +01:00
Lennart Spitzner 508780466c Adapt for butcher-0.2.0.0 2016-10-01 19:06:55 +02:00
Lennart Spitzner 1b7576dcd1 Fix --ghc-options handling 2016-09-06 15:29:13 +02:00
Lennart Spitzner cb93a6903c Fix horizontal alignment issue; Add testcases 2016-09-04 14:24:19 +02:00
Lennart Spitzner a29836d09c Refactor module structure; Clean up imports 2016-09-04 00:24:20 +02:00
Lennart Spitzner b03996e401 Apply brittany on parts of its source; Add comments 2016-09-03 23:02:32 +02:00
Lennart Spitzner 3809ba9ef0 Fix some type sig layouting minor issue 2016-09-03 21:50:31 +02:00
Lennart Spitzner 48b2057d84 Improve horizontal alignments significantly (patterns) 2016-09-03 21:32:18 +02:00
Lennart Spitzner fc47372005 Restore aligning on non-function bindings 2016-09-02 00:38:56 +02:00
Lennart Spitzner 371fad303d Improve column aligning; Add config for aligning 2016-09-02 00:38:56 +02:00
Lennart Spitzner 395fe02644 Stop aligning patterns for different functions 2016-09-02 00:06:49 +02:00
Lennart Spitzner 8218b6e199 Fix tuple type multiline layouting 2016-09-01 15:19:56 +02:00
Lennart Spitzner 40509dc3f0 Fix comment omission on type vars and qual type 2016-09-01 14:37:17 +02:00
Lennart Spitzner fedfeaaecd Improve HsLam and OpApp layouting 2016-09-01 13:49:30 +02:00
Lennart Spitzner 8277e85187 Fix NonBottom/setBaseY getSpacing(s) interaction
- Rename NonBottom -> Always
2016-09-01 12:35:11 +02:00
Lennart Spitzner cc9b1f6885 Fix comment placement for HsIf/HsLet 2016-08-18 15:27:10 +02:00
Lennart Spitzner d0fcfc563e Fix if-then-else comment placement issue 2016-08-18 01:14:11 +02:00
Lennart Spitzner e67855fd98 Fix list comprehension comment placement issue 2016-08-18 00:59:12 +02:00
Lennart Spitzner b58a8b0146 Fix commandline flag parsing (again, oops) 2016-08-12 20:57:37 +02:00
Lennart Spitzner 59cee6fb0e Fix output validity check extensions missing 2016-08-12 17:05:50 +02:00
Lennart Spitzner fb1aeb5739 Fix error printing to stdout->stderr 2016-08-12 15:01:15 +02:00
Lennart Spitzner 0229a50785 Replace all `briDocByExact` by `unknownNodeError` 2016-08-12 15:01:15 +02:00
Lennart Spitzner d444c6e386 Add check of syntactic validity of output 2016-08-12 15:01:15 +02:00
Lennart Spitzner bc09b21473 Fix endOfFile placement bug when there are multiline comments 2016-08-12 15:01:15 +02:00
Lennart Spitzner 39e565c182 Fix RecordUpd comment placement bug 2016-08-12 15:01:15 +02:00
Lennart Spitzner b045c37bbd Fix two column layouting bugs 2016-08-12 15:01:15 +02:00
Lennart Spitzner d30a712a75 Fix line length calculation for column layouting 2016-08-12 15:01:15 +02:00
Lennart Spitzner dd60900da4 Layout NegApp, RecordUpd with pun; Add some AnnKW 2016-08-12 15:01:15 +02:00
Lennart Spitzner 46ad20e8f9 Add comment-aware alternative filtering (type sig) 2016-08-12 15:01:15 +02:00
Lennart Spitzner 55709c9b17 Fix do let comment indentation problems 2016-08-12 15:01:14 +02:00
Lennart Spitzner 0a41843efd Fix tuple parenthesis printing 2016-08-12 15:01:14 +02:00
Lennart Spitzner 5166b3dd9e Improve comment handling (Add KW node; annotation transform) 2016-08-12 15:01:14 +02:00
Lennart Spitzner 5409b86adf Add help to --ghc-options commandline flag 2016-08-12 15:01:14 +02:00
Lennart Spitzner dd24316941 Fix the Semigroup.Last aeson instances (config breaking change :/) 2016-08-12 14:35:17 +02:00
Lennart Spitzner 6011726389 Show yaml representation when dumping config 2016-08-08 17:59:29 +02:00
Lennart Spitzner 1a70e4d949 Support --ghc-options; Rework config internals 2016-08-08 17:59:29 +02:00
Lennart Spitzner d625c90461 Refactor Main/Brittany.hs, code structure 2016-08-08 17:34:17 +02:00
Lennart Spitzner 23f19e653f Improve config file handling (local+user conf files) 2016-08-07 15:14:57 +02:00
Lennart Spitzner 214653bee5 Handle wildcards in expr/type 2016-08-07 14:26:27 +02:00
Gurkenglas bcdfea8654 Factor out a return 2016-08-06 23:31:27 +02:00
Lennart Spitzner b1f915d1c2 Change bounded search algorithm (change invariant) 2016-08-06 22:27:30 +02:00
Lennart Spitzner cd9474a969 Change layouting for lambda, app; Fix exponential behaviour 2016-08-06 19:36:47 +02:00
Lennart Spitzner 0314569276 Implement/Improve record pun handling (Pat/Expr) 2016-08-06 15:03:45 +02:00
Lennart Spitzner b4f749ea0c Fix comment handling CPP special case 2016-08-06 15:03:45 +02:00
Lennart Spitzner f54e3c6079 Some layouting improvements/fixes 2016-08-06 14:07:52 +02:00
Lennart Spitzner 52a4f7c11c Implement pattern cases: {..} and ~ 2016-08-06 14:07:13 +02:00
Lennart Spitzner 7f69ab8b43 Fix some record pattern case involving "pun" 2016-08-06 14:05:42 +02:00
Lennart Spitzner 705286be0a Fix parenthesized operator printing 2016-08-06 14:03:45 +02:00
Lennart Spitzner a1c153f0c5 Fix BDLines handling in getSpacings 2016-08-06 14:02:11 +02:00
Lennart Spitzner 02ee54f806 Fix EnsureIndent handling 2016-08-06 14:01:38 +02:00
Lennart Spitzner 449d4b4787 Add BDDebug node to BriDoc 2016-08-06 13:59:05 +02:00
Lennart Spitzner 1c5795f718 Add Set/ForceParSpacing flag special bridoc constructors 2016-08-06 13:51:54 +02:00
Lennart Spitzner 4d650306c0 Implement a first pre-processing annotation transformation 2016-08-06 00:13:50 +02:00
Lennart Spitzner 6b748ea3eb Respect special where ind.; Some layouting fixes 2016-08-04 19:53:37 +02:00
Lennart Spitzner 9949ed7225 Fixup for HEAD~2 2016-08-04 19:50:31 +02:00
Lennart Spitzner 87e81189c9 Various layouting fixes 2016-08-04 15:12:05 +02:00
Lennart Spitzner a82d38fa70 Make cols work around SetBaseY/SetIndentLevel 2016-08-04 15:10:44 +02:00
Lennart Spitzner 982e19b8b9 Fix type equality roundtripping 2016-08-04 11:18:31 +02:00
Lennart Spitzner c6eb7a71b8 Slightly improve column layouting (overflow) behaviour 2016-08-04 11:17:46 +02:00
Lennart Spitzner fb2483242a Add evil workaround for CPP comment indentation 2016-08-04 11:15:33 +02:00
Lennart Spitzner 8b0300df83 Remove docAlt spacing transpose trick 2016-08-04 11:14:27 +02:00
Lennart Spitzner 1ce40c861c Various minor layouting fixes 2016-08-03 22:13:41 +02:00
Lennart Spitzner 24dffbfe55 Fix transpose --> getZipList . traverse ZipList 2016-08-03 01:25:39 +02:00
Lennart Spitzner 986a720ca8 Make newlining "lazy" in backend 2016-08-02 13:54:56 +02:00
Lennart Spitzner 58c2bfbcc8 Minor cleanup, Add -rtsopts to unittests 2016-08-02 13:54:56 +02:00
Lennart Spitzner f96dceb74b Implement HsLet/ExprWithTySig/NPat 2016-08-02 13:54:56 +02:00
Lennart Spitzner 1dafdab68a Cleanup outcommented,old code 2016-07-30 15:56:02 +02:00
Lennart Spitzner 60d1bc5176 Squash previous history 2016-07-30 15:22:07 +02:00