Skip to content
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

Eliminate subtyping around type signal #59

Closed
aantron opened this issue Oct 22, 2020 · 2 comments
Closed

Eliminate subtyping around type signal #59

aantron opened this issue Oct 22, 2020 · 2 comments
Labels

Comments

@aantron
Copy link
Owner

aantron commented Oct 22, 2020

Several functions in Markup.ml accept narrower types than signal. For example,

val pretty_print : ([> content_signal ] as 'a, 's) stream -> ('a, 's) stream

These functions are difficult to modify freely, for example as in #58.

The only function in Markup.ml that produces a stream with a narrower type than signal is content:

markup.ml/src/markup.mli

Lines 548 to 550 in b4b59ae

val content : ([< signal ], 's) stream -> (content_signal, 's) stream
(** Converts a {!signal} stream into a {!content_signal} stream by filtering out
all signals besides [`Start_element], [`End_element], and [`Text]. *)

If this were just (signal, 's) stream -> (signal, 's) stream, it would force users only to add a wildcard case to any pattern matching they do on the signals. Conversely, the benefit would be a library interface that is shorter, easier to understand, and an implementation that is much easier to edit.

@aantron
Copy link
Owner Author

aantron commented Oct 22, 2020

plist-xml is the only publicly-visible project I was able to find that would be affected by this. @alan-j-hu, what do you think about replacing content_signal and most row types in Markup.ml with just signal?

I am considering doing this and re-releasing it as part of a retagged 1.0.0.

Sorry about the churn. I realize you just updated your deps to allow Markup 1.0.0, and now this comes up :P

See #58 (comment) for the current motivation behind doing this. I also had similar issues during the original development of Markup, but I managed to massage all the types in the original release to fit.

alan-j-hu added a commit to alan-j-hu/opam-repository that referenced this issue Oct 23, 2020
This change is done to accomodate
aantron/markup.ml#59.
@alan-j-hu
Copy link

Okay, I just opened a PR on ocaml/opam-repository to downgrade markup back to below 1.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants