Add operations on refined typed
See original GitHub issueWould be great to have a subset of the same operations available on unconstrained typed also available on refined types but tracking properties across operations. Even a small subset would probably already be a big win. I am thinking things like:
scala> val a: Int Refined Greater[W.`5`.T] = 10
scala> a + 1
res0: Int Refined Greater[W.`6`.T]
Are there any operations like this already? If not, adding a few to open the door for contributions in the same style might be a good way to get started.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:9 (6 by maintainers)
Top Results From Across the Web
How we used Refined to improve type safety and error ...
Today, we are going to talk about a way to refine our types to make them more expressive and increase confidence in our...
Read more >Refinement Types in Typed Racket
This refinement type describes values i of type Integer such that (<= 0 i (- (vector-length v) 1)) produces #true . The documentation...
Read more >Safe, Expressive Code with Refinement Types - OVO Tech Blog
In this blog post I will explore refinement types and their implementation in Scala's refined library. Refinement types are a powerful tool ...
Read more >Programming with Refinement Types
Programming with Refinement Types. An Introduction to LiquidHaskell. Ranjit Jhala, Eric Seidel, Niki Vazou. [PDF] · 1.Well-Typed Programs Can Go Wrong.
Read more >Build your own refinement types in Scala 3 - Michał Sitko blog
We had to add another type parameter in addition to the predicate. To express that that Refined[T, Predicate] type was introduced. You can...
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
With the addition of “companions” for predefined refined types there is now a suitable place for operations with these types. For example, I experimented with addition of
NonNegInt
s here: https://github.com/fthomas/refined/blob/76d812c3508e45e6413914dd76a81908ae5cf1db/modules/core/shared/src/main/scala/eu/timepit/refined/types/numeric.scala#L19-L28 Which preserve the non-negative property even in case of overflows:eg.