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

Expose constructors for interval types #1325

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LaurenceWarne
Copy link

@LaurenceWarne LaurenceWarne commented Mar 19, 2024

Hi! I'd like to use intervals for which I know for example are only going to be of type [a, ∞), but using the constructor Interval.atOrAbove returns an Interval rather than an Above instance, so the ability to extract the lower bound as an exact ValueBound using x.lowerBound is lost AFAICS.

I think changing the return types would break binary compatibility, so this PR adds new methods on the companion which are in turn called by the corresponding methods on Interval, specifically for:

  • Above
  • Below
  • All
  • Empty

I think the constructors for these objects were leaked before, and included the internal flags value, and in general I'm not sure how much the Above, Below, etc are intended for general usage, but let me know any thoughts anyway 🙂

Thanks!

@armanbilge
Copy link
Member

armanbilge commented Mar 19, 2024

Thanks for the PR!

I think changing the return types would break binary compatibility

Actually I think we can do this without breaking compatibility. Instead of changing the return type, add a new method of the same name with the desired return type. Meanwhile, make the old method private and add a dummy type parameter to disambiguate e.g.

object Foo {
  // old
  private[Foo] def bar[DummyParameter](x: Int): AnyRef = ???
  // new
  def bar(x: Int): String = ???
}

@LaurenceWarne
Copy link
Author

Actually I think we can do this without breaking compatibility. Instead of changing the return type, add a new method of the same name with the desired return type. Meanwhile, make the old method private and add a dummy type parameter to disambiguate e.g.

Nice! Though I find sbt mimaReportBinaryIssues still doesn't seem to like it: https://github.com/typelevel/spire/actions/runs/8364280484/job/22899223855?pr=1325#step:15:33?

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

Successfully merging this pull request may close these issues.

None yet

2 participants