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

Check if extensions and givens behave correctly with the new RefinedType definiton #296

Closed
Iltotore opened this issue Feb 25, 2025 · 1 comment
Labels
breaking changes Changes that break compatibility with older versions question Further information is requested
Milestone

Comments

@Iltotore
Copy link
Owner

Check if this:

type Temperature = Temperature.T
object Temperature extends RefinedType[Double, Positive]:
  extension (a: Temperature)
    def +(b: Temperature): Temperature = ???

  given Ordering[Temperature] = ???

Are not considered "orphan" givens/extensions by the compiler. This could be an important ergonomic regression and therefore need to be checked before releasing the new definition.

@Iltotore Iltotore added breaking changes Changes that break compatibility with older versions question Further information is requested labels Feb 25, 2025
@Iltotore Iltotore added this to the 3.0.0 milestone Feb 25, 2025
@Iltotore
Copy link
Owner Author

Iltotore commented Mar 2, 2025

Seems to work 🎉

package newtypes

import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.all.*

type WinCount = WinCount.T
object WinCount extends RefinedType[Int, Positive0]:

  extension (a: WinCount)
    def +(b: WinCount): WinCount = WinCount.assume(a.value + b.value)

  given Ordering[WinCount] = WinCount.assumeAll(Ordering.Int)
import newtypes.WinCount

object Main:

  @main
  def testMain =
    val x = WinCount(1) + WinCount(2)
    summon[Ordering[WinCount]]
    println(x)

@Iltotore Iltotore closed this as completed Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Changes that break compatibility with older versions question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant