Skip to content
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 Semiring and Ring instances for Perm #15

Merged
merged 1 commit into from
Jul 5, 2015

Conversation

michaelficarra
Copy link
Contributor

Untested, since I don't see any tests. 😅

@hdgarrood
Copy link
Member

This is very pleasing. :)

Fair enough re tests. I think it should be ok to wait until psc 0.7 and then use https://github.com/purescript/purescript-quickcheck-laws.

Do you think it would make sense to remove the Semigroup instance, and get people to use (+) where they would currently use (<>)? eg mkPerms (read + write) read read. Then people could use Data.Monoid.Additive or Data.Monoid.Multiplicative if they want to use Perm with something like foldMap.

@hdgarrood
Copy link
Member

Also, I'm not sure the Ring instance is valid. Considering a Boolean Ring instance with (-) as implication, I think we need negate a to be the additive inverse of a for all a, that is, a + (negate a) == zero. However:

true + (negate true)
= true + (zero - true)
= true + (zero && not true)
= true + (false && not true)
= true + false
= true || false
= true
/= zero

edit: sorry, I've just realised that a && not b isn't implication, it's the negation of implication. I think the above still holds, however.

@hdgarrood
Copy link
Member

I think a Ring instance for Boolean is impossible - we would need (zero - a) + a = zero for all a. If we take true as a, we then need (false - true) + true = false. Then, it doesn't matter how we define (-), because (following from the properties of boolean or) b + true = true holds for all b.

@michaelficarra
Copy link
Contributor Author

I removed the Ring instance.

@hdgarrood
Copy link
Member

How do you feel about removing the Semigroup instance?

hdgarrood added a commit that referenced this pull request Jul 5, 2015
@hdgarrood hdgarrood merged commit fe62b9c into purescript-node:master Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants