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

Should we merge RefinedTypeOps#apply and #fromIronType? #130

Closed
Iltotore opened this issue Jun 14, 2023 · 0 comments · Fixed by #139 or #141
Closed

Should we merge RefinedTypeOps#apply and #fromIronType? #130

Iltotore opened this issue Jun 14, 2023 · 0 comments · Fixed by #139 or #141
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Iltotore
Copy link
Owner

Currently, given this code:

opaque type Age = Int :| Positive
object Age extends RefinedTypeOps[Age]

We should use apply to create an Age from an Int and fromIronType to get an Age from a refined type like Int :| Positive.

If we change the RefinedTypeOps#apply method definition to:

def apply(value: A :| C): T = value

where:

  • A is the "raw" type (e.g Int)
  • C is the constraint (e.g Positive)
  • T is the opaque type (e.g Age)

This code would compile:

val a: Age = Age(15)

val x: Int :| Positive = ???
val b: Age = Age(x)

Here are two concerns:

  • Is it better to use the same method instead of apply and fromIronType? (I think so)
  • Does it bring any reggression compared to current apply-fromIronType separation?

Since you made the current RefinedTypeOps implementation @antonkw, what do you think?

@Iltotore Iltotore added the enhancement New feature or request label Jun 14, 2023
@Iltotore Iltotore added this to the 2.2.0 milestone Jun 14, 2023
@Iltotore Iltotore self-assigned this Jun 21, 2023
Iltotore pushed a commit that referenced this issue Jul 2, 2024
It seems like `fromIronType` was combined with `apply` in
`RefinedTypeOps`, but there are a few lingering references in the
Scaladoc to the removed API member. This PR removes those references.

Close #248 

Related: #130 #139 #140
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment