Boolean refinements "weak"
- Dominant language
- Scala
- Stars
- 1.7k
- Forks
- 152
- Avg merge
- 1h 20m
- Merged PRs (30d)
- 6
Description
The title sucks, I know :)
The following is an annoying thing `refined` allows but should probably not be allowed.
I also think that some kind of type bound or self-typing may be able to solve this, although I have not looked into it at all.
Imagine this code:
```scala
type Foo = String Refined NonEmpty And MaxSize[W.`10`.T]
```
Looks fine until you realize it makes no sense at all (but compiles!).
```scala
typeOf[Foo].dealias.toString
res23: String = "eu.timepit.refined.boolean.And[eu.timepit.refined.api.Refined[String,eu.timepit.refined.collection.NonEmpty],eu.timepit.refined.collection.MaxSize[Int(10)]]"
```
So we have an `And[Refined[String, NonEmpty], MaxSize[10]]`. Is there an actual use case for `Refined` being a type parameter to any of the boolean operators? I can't think of one.
What I actually would want is this:
```scala
type Foo = String Refined (NonEmpty And MaxSize[W.`10`.T])
typeOf[Foo].dealias.toString
res21: String = "eu.timepit.refined.api.Refined[String,eu.timepit.refined.boolean.And[eu.timepit.refined.collection.NonEmpty,eu.timepit.refined.collection.MaxSize[Int(10)]]]"
```
To my understanding, there is no way we can make `Refined` "weaker". But this should at least be a compile error without the parentheses, should it not?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.