-
Notifications
You must be signed in to change notification settings - Fork 15
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 terminal.unix
to re-expose size functions
#43
Conversation
I think it's a plus if it's self-contained as it makes the build faster, doesn't it? And yes not having any breakage is even more optimal. Thanks! |
Yeah that kind of makes sense with the existing lib structure as |
include | ||
module type of Terminal_ansi | ||
with type Color.t = Terminal_ansi.Color.t | ||
and type Style.t = Terminal_ansi.Style.t |
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 is a bit ugly, but we have a diamond dependency:
terminal.ansi <------- terminal
^ ^
| |
progress.engine <----- progress
and progress
needs to see that terminal
and progress.engine
are using the same color/style types.
….unix to terminal
(language c) | ||
(names terminal_stubs)) | ||
(libraries | ||
(re_export terminal_ansi) |
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.
I'm not sure to really understand the re_export
field. That means that if unix
is found as a dependency, we integrate terminate_ansi
?
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.
I don't understand re_export
either and copied that trick from progress/dune
, but it doesn't work without it as e.g. Terminal.Color
is now a module alias to Terminal_ansi.Color
and without re_export
the Terminal_ansi
would be missing and cause compilation error (so a user would need to always depend on both terminal terminal.ansi
rather than just terminal
)
(The re_export
doesn't have anything to do with unix
being available, a mirageos unikernel would depend on terminal.ansi
and ignore the unix-dependent terminal
lib, just like it would need to depend on progress.engine
and wouldn't be able to use the unixy progress
lib)
I'm not sure I understand this PR. I think I understand that you're trying to ‘revert’ #38 by re-exporting the same API but with a rather obscure trick to maintain compatibility with Mirage. From my point of view, it might be ‘simpler’ to export a new |
No problemo, there are two commits in the PR :) The first commit adds I'm happy to remove the second commit which attempts to restore backward compatibility by copying the design of the
I don't have a strong preference either way, but I think the original library organization was attempting for unix users to be the happy path (just depend and use |
Ok, I see the trick now. It seems indeed the painless solution for @msprotz. I will merge an cut a release. Thanks for your time - I will probably extends your PR with some comments to explain the Mirage path. |
…void the unix dependency from this library to progress.engine
CHANGES: - Revert the `terminal` API and keep an "happy" path to get size of a tty and be compatible with MirageOS (@art-w, @msprotz, craigfe/progress#42, craigfe/progress#43) - Use a `float` instead of a `int` in `flow_meter per-second` (@mbarbin, craigfe/progress#23, craigfe/progress#27)
In #38, I introduced a breaking change by removing the terminal size functions as they were dependent on
unix
and were incompatible with mirage usage. But I wrongly assumed that these functions were only used byprogress
, while there are in fact users who depended on them to measure the terminal dimensions (see #42). This new PR introducesterminal.unix
to re-expose the size functions.@dinosaure or @msprotz > Would you prefer if
terminal.unix
was self-contained? eg:In which case, could we rename/swap the two libraries, eg
terminal => terminal.ansi
andterminal.unix => terminal
, to fully hide the breaking change from existing users?