Giter Site home page Giter Site logo

Add Show typeclass about algebra HOT 3 CLOSED

typelevel avatar typelevel commented on July 27, 2024
Add Show typeclass

from algebra.

Comments (3)

johnynek avatar johnynek commented on July 27, 2024

Eq and Hash are lawful and useful to algebraic code. I wish scala had a Show typeclass, but I'd tend say we should not have it here. You have a barrier against the slippery slope: adding only typeclasses implied by Object, but still I'm weakly opposed.

Next, other than style, I'm not sure what is that bad about .toString. I mean, I would not design a new language with .toString on everything, but given that Java and scala already did that, I'm not sure the win of having Show other style purity.

from algebra.

rklaehn avatar rklaehn commented on July 27, 2024

I see your point of view.

About why having Show: often implementing toString requires access to typeclass instances. So you have to capture the typeclass instances into your data structures in order to implement toString, which is inefficient, and also drives you to a more OO design.

from algebra.

tixxit avatar tixxit commented on July 27, 2024

Yeah - a good point. I don't think toString is too bad, but an example in Spire is that we often have to use this really nasty hack to work with generic values when we don't have a type class available to help us. This shows up more when implementing equals and many of the ScalaNumber methods :\

That said, I'd rather not have Show here as well.

from algebra.

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.