-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add Bounded typeclass #1536
Comments
Why must I don't believe that Haskell's iPrelude> :i Bounded
class Bounded a where
minBound :: a
maxBound :: a |
It is correct but in this case |
What laws must a reference - http://stackoverflow.com/questions/43029076/type-class-w-min/43029124?noredirect=1#comment73326210_43029124 |
@kevinmeredith see my first comment (such as ...) |
This seems to not be |
I'm not crazy about Bounded. Would prefer LowerBounded and UpperBounded. String, for instance is LowerBounded. NonNegative numbers are LowerBounded. There are some examples of only UpperBounded as well. |
I agree with @johnynek it would be more useful to one typeclass for upper and another for lower bound. Here is an example https://github.com/julien-truffaut/newts/blob/master/core/shared/src/main/scala/newts/Min.scala#L35 |
For lawless typeclasses, we might also want to consider adding them to alleycats instead, especially if they are not that "core" and we still intend to keep cats.core lean. |
I don't see how his is lawless when it has an associated Ordering. So, they could extend Order and everything is fine, no? |
@johnynek I didn't make it clear. I was referring to LowerBounded and UpperBounded. |
trait LowerBounded[A] extends Order[A] {
// law: compare(minValue, a) <= 0 for all a
def minValue: A
} I'm probably missing it, but how is that lawless? Maybe I'm missing context? |
Ah for some reason I thought your upper and lower bound isn't order associated, now I have no idea how I got that impression. My bad. |
No problem. In thinking about this more, we probably want this to extend PartialOrder so it can represent the top and bottom of any Lattice, but then maybe indeed these are equivalent to bounded meet and bounded join semi lattices as @edmundnobel suggests. |
Hi everyone. I've got the following implementation of Enum and Bounded type classes here: https://github.com/izeigerman/scalanum . Is there any chance for it to be included into Cats? Is it missing anything else beside the integration with |
I like the idea of adding these type classes to Cats. Just a couple of ideas, I think the laws could be expressed as |
Hey @izeigerman are you still interested in getting included into Cats? I'm sorry no one ever got back to you, but I think this is definitely still on the table :) |
@LukaJCB, yes, I still am! Will create a PR soon. |
Awesome, thank you! |
@LukaJCB Quick question though: I'm having a hard time coming up with laws for |
I think we should start with adding |
Closed by #2913 |
such as
min(a, minValue) == minValue
andmax(a, maxValue) == maxValue
The text was updated successfully, but these errors were encountered: