Code Monkey home page Code Monkey logo

Comments (4)

johnynek avatar johnynek commented on June 12, 2024

cc @non

We implemented this stuff a very long time ago and may well have made a few mistakes in the encoding.

How should this have been encoded? It seems that extending GCDRing was a mistake in your view, but we don't have GCDRig do we? So I wonder if the hierarchy has greater issues in this regard.

What do you propose as our best course of action?

from cats.

benhutchison avatar benhutchison commented on June 12, 2024

I think the "right" (ideal) representation would extend a EuclidianRig from Rig. AFAICT Euclidian doesn't need negation in its sematics or laws, and there could be a valid instance for natural numbers without subtraction.

I like the way NumHask models algebra, although the names are different. NumHask's Integral ~ Cats EuclidianRing and it extends Distributive, which ~ Cats Rig.

Possibly the "right" (pragmatic) solution is to mark this issue as Won't fix and simply leave it as a signpost for the next generation of library writers. Its likely a breaking change and I'd guess very few people care.

I don't have strong knowledge or views on why GCDRing is separated from EuclidianRing. Is there any known trait that extends GCDRing but not EuclidianRing?

from cats.

johnynek avatar johnynek commented on June 12, 2024

I wouldn't be surprised if no one has ever used this code. The breakage cross section may be very low here.

That said, an abstraction that is never used it also tautologically not useful. I imagine that you can add a trait to your own code just as well if you intend to use it.

If we had confidence of the improvement adding a new trait costs very little.

from cats.

benhutchison avatar benhutchison commented on June 12, 2024

Well, I think a solution could be to

  • new trait GCDRig extending Rig
  • new trait EuclidianRig extending GCDRig.
  • existing GCDRing would now extend Ring and GCDRig
  • existing EuclidianRing would now extend GCDRing and EuclidianRig

Practically this would allow natural numbers to be supported since they can provide a EuclidianRig[Nat]

from cats.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.