Conversation
|
Perhaps we can remove |
| -- | ``` purescript | ||
| -- | odd 0 == false | ||
| -- | odd 1 == false | ||
| -- | odd 1 == true |
| data Parity = Even | Odd | ||
|
|
||
| derive instance eqParity :: Eq Parity | ||
| derive instance ordParity :: Ord Parity |
There was a problem hiding this comment.
Good thinking. I added Bounded also.
There was a problem hiding this comment.
It's a field, isn't it, if we're going to give it numeric instances? If we treat Parity as Z/2Z with Even = [0] and Odd = [1]?
There was a problem hiding this comment.
I'm thinking of this as being an approximation to integers, not Z/2Z. Dividing an even integer by another even integer could be even or odd.
There was a problem hiding this comment.
Although I think sometimes "ring" is defined such that multiplication need only be a semigroup, not necessarily a monoid; in that case you might be able to find two such rings with two elements.
There was a problem hiding this comment.
Yeah your logic seems sound to me. I was going from this:
There was a problem hiding this comment.
Does that suggest that we should give Boolean a Field instance?
There was a problem hiding this comment.
I don't think we should. Just because it has two elements doesn't mean we should think of it as Z/2 in my opinion. I would rather have a separate type.
There was a problem hiding this comment.
Makes sense, although we can make it into a field without thinking of it as Z/2Z - just by thinking of addition as xor and multiplication as &&. But yeah in the absence of any concrete use case I'm inclined to leave it how it is too.
No description provided.