Greg Hurrell [Fri, 10 Jun 2016 01:02:18 +0000 (18:02 -0700)]
Turn on -Wall -Werror -W
I think we're clean even with all these turned on. Great. Want this now that we
are not being explicit about imports.
Some tweaks needed to keep the tests clean. Notably, to deal with:
Defaulting the following constraint(s) to type ‘Integer’
(Eq a0) arising from a use of ‘@=?’ at tests/Tasty.hs:35:7-9
(Num a0) arising from the literal ‘7’ at tests/Tasty.hs:35:5
(Show a0) arising from a use of ‘@=?’ at tests/Tasty.hs:35:7-9
(Num a0) arising from a use of ‘walk’ at tests/Tasty.hs:48:30-33
Need to opt out of `-fwarn-type-defaults` in Tasty.hs.
Greg Hurrell [Fri, 10 Jun 2016 01:00:39 +0000 (18:00 -0700)]
Cut back on explicit imports as per the GHC style guide
Quoting:
> Do not use explicit import lists, except to resolve name clashes. There are several reasons for this:
>
> - They slow down development: almost every change is accompanied by an import
> list change.
> - They cause spurious conflicts between developers.
> - They lead to useless warnings about unused imports, and time wasted trying
> to keep the import declarations "minimal".
> - GHC's warnings are useful for detecting unnecessary imports: see
> `-fwarn-unused-imports`.
> - TAGS is a good way to find out where an identifier is defined (use `make tags`
> in `ghc/compiler`, and hit `M-.` in emacs).
Greg Hurrell [Thu, 9 Jun 2016 14:11:59 +0000 (07:11 -0700)]
Try to make `toc` more readable
Instead of threading the `suffix` through multiple layers of function calls,
create a new scope with an inner function `toc'` that we can use to have
implicit access to it instead.
I think this might be more readable, although it is still somewhat of a hot
mess.
Greg Hurrell [Wed, 8 Jun 2016 14:10:51 +0000 (07:10 -0700)]
Improve ordering in the compiler
Make the footer go at the end. Not that the order matters, this just looks
better. (And speaking of the ordering not matter, that makes me wonder if there
is something Applicative I could to here... Probably not. Also thinking of using
a State monad or even just a simple fold to get rid of those intermediate
bindings.)
Greg Hurrell [Wed, 8 Jun 2016 01:41:34 +0000 (18:41 -0700)]
Avoid unwanted intermediate list in `cosmosOf uniplate`
Who knows: perhaps Haskell's magical laziness would have made these equivalent,
or perhaps this still ends up producing an intermediate list. But at least it
*looks* better.
Figured out by poring over the function list in the lens docs looking for likely
candidates.
Greg Hurrell [Tue, 7 Jun 2016 16:26:51 +0000 (09:26 -0700)]
Add Section visitor
It's job is to check which kinds of annotations we have, in order to decide
which sections we need to render.
I am probably doing something clowny with the way I am mashing uniplate and
lenses etc together, but it does seem to work. That last `get`/`put` case is a
smell, but needed it given my use of `cosmosOf`; not sure how to avoid that.
Also, not sure why `mapM` does the right thing here, but it does.
Greg Hurrell [Tue, 7 Jun 2016 14:29:42 +0000 (07:29 -0700)]
Try to trick linter about duplication
It's been warning about this since forever:
```
Found:
first <- firstLine
rest <- many otherLine
let nodes = concatMap appendWhitespace (first : rest)
let compressed = compress nodes
return
(if last compressed == Whitespace then init compressed else
compressed)
Why not:
Combine with lib/Docvim/Parse.hs:202:7
lib/Docvim/Parse.hs:164:7: Warning: Reduce duplication
Found:
first <- firstLine
rest <- many otherLine
let nodes = concatMap appendWhitespace (first : rest)
let compressed = compress nodes
return
(if last compressed == Whitespace then init compressed else
compressed)
Why not:
Combine with lib/Docvim/Parse.hs:285:7
```
However, it is too smart. Even with this change, it still complains:
```
Found:
first <- firstLine
rest <- many otherLine
let nodes = concatMap appendWhitespace (first : rest)
let compressed = compress nodes
return
(if last compressed == Whitespace then init compressed else
compressed)
Why not:
Combine with lib/Docvim/Parse.hs:282:7
lib/Docvim/Parse.hs:165:7: Suggestion: Reduce duplication
Found:
rest <- many otherLine
let nodes = concatMap appendWhitespace (first : rest)
let compressed = compress nodes
return
(if last compressed == Whitespace then init compressed else
compressed)
Why not:
Combine with lib/Docvim/Parse.hs:203:7
```
This one is tricky to factor out because of the dependence on bindings visible
within the scope of the defined functions, and also the monadic execution
context. I think the linter *is* probably right that there is a code smell here,
though; I just have to figure out how to remove it.
Greg Hurrell [Tue, 7 Jun 2016 02:04:40 +0000 (19:04 -0700)]
Make wrapping aware of concealed characters
This is the cheap-but-approximate approach. Results are reasonable, costs are
very low, and the consequences of being (slightly) wrong are livable. Let's go
with this for now.
Greg Hurrell [Mon, 6 Jun 2016 13:55:27 +0000 (06:55 -0700)]
Initial cut at @mapping, @command, @option, @function
Still some bugs to sort out (eg. duplicate symbol table entry due to extra
`MappingsAnnotation` when we perform extraction) and polish to apply (not
actually printing the options/functions etc).
Greg Hurrell [Sun, 5 Jun 2016 14:06:32 +0000 (07:06 -0700)]
Overhaul testing and compilation
We now "compile" in the test suite, meaning that we pipe our translation units
through the various extraction transforms after parsing. This means three main
things:
- Everything is nested inside a `Project` node type now, consisting of one or
more translation units.
- Nodes within the project are ordered (or reordered) to maintain desired
section ordering.
- As we add more phases to "compilation" (eg. automated insertion of table
of contents etc), these will get reflected in the test suite automatically.
As part of this, extracted test-specific bits out into a new `Util` module (ie.
pretty-printing methods, convenience functions) and the "compile" pipeline into
a `Compile` module.
Greg Hurrell [Sat, 4 Jun 2016 22:01:56 +0000 (15:01 -0700)]
Move hardwrapping from `plaintext` into `append`
Solves a bunch of issues, creates others, which I will have to fix in a
follow-up. The code itself is a complex, fragile, ugly, clusterfuck, so consider
this a work-in-progress.
Additionally, there are some unfortunate breaks which were there before and
continue to be there, like just inside parens, and things like that. Will need
to sort all that out too.