-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add hardLine to force line breaks #181
Conversation
Codecov Report
@@ Coverage Diff @@
## master #181 +/- ##
=========================================
- Coverage 97.84% 97.7% -0.15%
=========================================
Files 4 4
Lines 279 305 +26
Branches 27 38 +11
=========================================
+ Hits 273 298 +25
- Misses 6 7 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! I saw two minor issues which should be pretty easy to fix.
@@ -800,6 +867,23 @@ object Doc { | |||
* Collapse a collection of documents into one document, delimited | |||
* by a separator. | |||
* | |||
* This works identical to the following code, but is much |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small grammar problem, should be "This works identically to the following code..." or possibly "This is equivalent to the following code"
import Doc._ | ||
val b0 = Concat(Text("b"), Union(Text(" "), FlatAlt(Line, Text(" ")))) | ||
val c0 = Union(Concat(Text("b"), Text(" ")), Concat(Text("b"), FlatAlt(Line, Text(" ")))) | ||
law(b0, c0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't commit this "raw AST" example -- I'd prefer to either delete it or use our combinators to build it up.
We don't want this as part of our public API, and we weren't testing it extensively.
I pushed a few more changes, I'm 👍 on everything else. @johnynek want to take a look and merge if OK? |
everything looks good! |
Great! 💯 |
What about release? I'm using fork because of lack of this feature, and I want to move back to vanilla :-) |
We will release in a few days after we get ANSI color codes in see #184 |
close #76
The inspiration here was to split #117 into two. The first part was #176 which we could add without relaxing laws. This is the second part which exposes the ability to make hardLine documents.
We only removed two laws:
Union(a + b, a + c) == a + Union(b, c)
is only true ifa
contains no hardLines.We found a simpler, but very similarly performing implementation (sometimes faster sometimes a bit slower) of fill which was easier to reason about and allowed us to not have to give up that combinator. Here are the benchmarks. The
x
suffix means the previous implementation:This does not make flatten and flattenOption private. Maybe we should. But it does change the contract: there is no guarantee there are no newlines, the result may have hardLine in them. It may be better to just make them private. I don't know if anyone really needs them.
This was work @non and I did together, but highly based on the excellent pathbreaking work of @seanmcl.
cc @olafurpg @seanmcl