Skip to content

Update Field#170

Merged
garyb merged 1 commit into
compiler/0.12from
field-constraints
May 13, 2018
Merged

Update Field#170
garyb merged 1 commit into
compiler/0.12from
field-constraints

Conversation

@garyb
Copy link
Copy Markdown
Member

@garyb garyb commented Apr 30, 2018

Resolves #132

@garyb garyb requested a review from hdgarrood April 30, 2018 11:04
@garyb garyb force-pushed the field-constraints branch from 95fbeb1 to f1d3571 Compare April 30, 2018 11:05
@hdgarrood
Copy link
Copy Markdown
Contributor

Every field is a euclidean ring, so I think it might be best to keep the EuclideanRing constraint. In fact with what's in this PR, you wouldn't be able to write a function which uses / and which only has a Field constraint, right?

How about this instead:

class (EuclideanRing a, DivisionRing a) <= Field a
instance (EuclideanRing a, DivisionRing a) => Field a

@hdgarrood
Copy link
Copy Markdown
Contributor

Also this relates to #132, not #128, right?

@garyb
Copy link
Copy Markdown
Member Author

garyb commented Apr 30, 2018

I did wonder about that, in the other PR I had it with the EuclideanRing constraint but then looking at it again today I thought that might have been a mistake 😄

@hdgarrood
Copy link
Copy Markdown
Contributor

Also I think it might be worth mentioning that every type with law-abiding DivisionRing and CommutativeRing instances only really has one sensible law-abiding EuclideanRing implementation, where div a b = a * recip b, mod _ _ = zero, and degree _ = 1; see https://a-guide-to-the-purescript-numeric-hierarchy.readthedocs.io/en/latest/euclidean-rings.html, where it says "start from "Let F be a field, and suppose f:F∖{0}→N is a euclidean function". degree must be constant; any return value will work, so you might as well choose 1.

@garyb garyb force-pushed the field-constraints branch from f1d3571 to 5817af2 Compare May 13, 2018 12:47
@garyb garyb force-pushed the field-constraints branch from 5817af2 to f7353cd Compare May 13, 2018 12:48
@garyb garyb merged commit 4507d01 into compiler/0.12 May 13, 2018
@garyb garyb deleted the field-constraints branch May 13, 2018 12:51
@hdgarrood
Copy link
Copy Markdown
Contributor

Sorry, I didn't notice you had updated this, but there's a couple of things I think are not quite right here (in the docs). Do you mind if I send another PR?

@hdgarrood
Copy link
Copy Markdown
Contributor

Oh actually, EuclideanRing implies CommutativeRing, so adding the CommutativeRing superclass won't do anything. With this commit, we have a Field Int instance, which is definitely wrong. It should have EuclideanRing and DivisionRing superclasses. I'll send a PR in a moment.

@garyb
Copy link
Copy Markdown
Member Author

garyb commented May 13, 2018

Oops, glad someone is paying attention 😉

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