question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Boolean refinements "weak"

See original GitHub issue

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:

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:open
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
fthomascommented, May 12, 2018

We could introduce a marker trait Predicate, let every predicate extends that, and then use a type bound in And: class And[A <: Predicate, B <: Predicate]. Refined would not be a Predicate and And[Refined, ...] would be a compile error.

0reactions
NeQuissimuscommented, Aug 31, 2018

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found