Giter VIP home page Giter VIP logo

Comments (3)

milessabin avatar milessabin commented on May 12, 2024

Could you clarify what you mean by "it would only produce instances for types derived from nongeneric classes"? Providing instances for (concrete instantiations of) polymorphic types (where well defined) is pretty much the whole point of Typeable, both here and in Haskell.

The key phrase in the above is "where well defined". It's well defined in the case of non-empty container-like things. It's clearly not well defined for function values. The reason your example has slipped through is that Typeable provides a fallback implicit for any type with a ClassTag available, in effect giving Java reflection an apparently parametricity respecting paintjob. That's pretty clearly wrong.

I wonder if dfltTypeable should just go, or is there an honest halfway house here? If it does go are there any additional types for which instances should be provided which aren't currently because they're being covered by the catch all case? At a minimum I suppose we could add an instance for any type with a Generic instance available.

Thoughts?

from shapeless.

S11001001 avatar S11001001 commented on May 12, 2024

Could you clarify what you mean by "it would only produce instances for types derived from nongeneric classes"?

class C
trait T
class GC[A]

There are instances for C and T for free, but GC[x] requires more, perhaps a Generic instance as fallback as you suggest.

from shapeless.

milessabin avatar milessabin commented on May 12, 2024

Gotcha ... the default case should only produce Typeable instances for nongeneric classes.

Agreed completely. Annoyingly this can only be done with a macro, but it's the right thing to do ... do you feel like taking a crack at it?

In principle it would be possible to do something for things with a Generic instance if Generic were itself polymorphic (ie. you could have a polymorphic Generic for case class Foo[T](t: T)). That's not supported yet ... it's something I'd like to do eventually.

from shapeless.

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.