-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(Tty): custom markers #175
Conversation
c2183a3
to
64c001d
Compare
The current code works but I'm not sure about the API. With this PR, the use_ansi:bool -> use_color:bool -> [`End_of_line | `End_of_file] option -> tag mark -> string that turns a "mark" into a string for display. I wonder how obvious this design is to library users without reading any documentation? |
4d3bde9
to
d09e62e
Compare
My initial reaction is "not very". (-: I'm guessing that the output of this function is supposed to be a string like "EOF" or "EOL". If so, why does it need to know about |
9ba916d
to
db5f1ec
Compare
@mikeshulman Your guess is correct. The reason for Here's the definition of (** A mark signals the start or end of a non-empty range, or the location of a point (a range of zero width). *)
type 'tag mark = 'tag MarkedSource.mark =
| RangeBegin of 'tag
| RangeEnd of 'tag
| Point of 'tag |
What is the Are all possible combinations of values for the |
@mikeshulman Here's the definition of (** The index type of all messages in a diagnostic. [ExtraRemark i] is the [i]th extra remark (indexes start from zero). *)
type index = MainMessage | ExtraRemark of int
(** A tag consists of an index (of type {!type:index}) and a message (of type {!type:Text.t}) *)
type tag = index * Text.t It should be impossible to have From the conversation, I guess my dream of "making the API self-explanatory" failed... but I'm not sure how to improve it. |
My rule of thumb is that if some combination of arguments is impossible, then the types should prevent that combination from occurring. Can those two arguments be combined into one, belonging to a datatype that enumerates the exact possibilities, exhaustively and non-overlappingly, with each constructor taking a fully flattened tuple of arguments that doesn't require looking up the definitions of other types to know what it contains? |
@mikeshulman Good point! I'll need more time to polish it. Another impossible combination is
PS: for the display function, the same combination ( |
In the display function, in practice would anyone really want any combination other than the four of |
@mikeshulman Here is the table. (There are actually only 7 valid choices because two have the same effect:)
I can imagine that colorblind people would want |
Ok, I guess 7 is close enough to 3x3 that having two arguments does make sense there. (-: |
ae6121f
to
e6ae4d8
Compare
e6ae4d8
to
3a0c2b9
Compare
Current progressI hope this type looks better now... type marker =
ansi:[ `Enabled_with_color | `Enabled_without_color | `Disabled ]
-> [ `Main_message | `Extra_remark of int ]
-> [ `Range_begin
| `Range_end of [`End_of_line | `End_of_file] option
| `Point of [`End_of_line | `End_of_file] option
]
-> string Remaining issues
|
Let me merge this first so that I can work on other radical changes. 😅 |
0e8ff1c
to
940b474
Compare
Update: now French double quotation marks (angle quotation marks) are used for non-empty ranges (e.g., «let x = 1») when ANSI escape sequences are disabled. This is probably the most compatible choice with the single quotes for point marks (e.g., ‹EOF›). (Maybe we should swap the single/double quotation marks?) |
The French quotes look fine to me. I would probably lean towards "alternative style 2". The type of
|
@mikeshulman Thanks. For Question 1, I was just not sure what constructor names to use without the labeling. What constructors would you suggest if the |
Hmm, maybe. |
No description provided.