Boolean refinements "weak"
See original GitHub issueThe 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:
type Foo = String Refined NonEmpty And MaxSize[W.`10`.T]
Looks fine until you realize it makes no sense at all (but compiles!).
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:
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?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
REFINEMENT PROPERTIES AND EXTENSIONS OF ...
Boolean algebra, disjoint refinement, ultrafilter, distributivity, Stone space, ... The weak power of cardinals, k-, as usual, equals 2{Ka: a is a cardinal,....
Read more >Refinement Properties and Extensions of Filters in Boolean ...
The weak power of cardinals, K?, as usual, equals {f Ka: a is a cardinal, a < X). The Frechet ideal on K,...
Read more >An Effective Theory of Type Refinements
to check that the first term M has a boolean refinement. ... The logic must contain a linear hypothetical judgment that can control...
Read more >Refinement monoids, equidecomposability types, and ...
Distributive lattices and Boolean rings. 15. 1.5. Commutative monoids, refinement monoids. 17. 1.6. Weak comparability and strict ...
Read more >Constrained existence problem for weak subgame perfect ...
Abstract: We study multiplayer turn-based games played on a finite directed graph such that each player aims at satisfying an omega-regular ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We could introduce a marker
trait Predicate
, let every predicate extends that, and then use a type bound inAnd
:class And[A <: Predicate, B <: Predicate]
.Refined
would not be aPredicate
andAnd[Refined, ...]
would be a compile error.Yeah, I don’t think we can do this with what we currently have. I have sort of given up since I’ve run into lots of different issues whenever I tried… Not sure how to solve this…