Giter VIP home page Giter VIP logo

Comments (3)

joroKr21 avatar joroKr21 commented on June 4, 2024

The last two lines are not syntactically equivalent. The inferred type is

inferKeys[FieldType["a", Int] :: FieldType["b", Int] :: HNil](record2)

It doesn't work with the singleton type (which is a subtype) because Keys is invariant.
You could use Keys[_ >: T] instead.

from shapeless.

tribbloid avatar tribbloid commented on June 4, 2024

@joroKr21 so type parameter cannot be inferred as singleton type even if the variable is declared so? Wow

The irony is that this correctly demonstrates the invariance you described:

type RR = record.type

val record2: RR =  ...

Really? The compiler is really mangled.

Regardless, my impression so far is that: it should be a valid improvement to make Keys contravariant to the input type, what do you think?

from shapeless.

joroKr21 avatar joroKr21 commented on June 4, 2024

If we apply variance it should be consistently to all type classes. But Scala 2 implicit resolution has quirks when it comes to variance, esp. contravariance. That would also be too big of a can of worms to open in Shapeless 2 I'm afraid. And since it has an easy workaround (use Keys[_ >: T] if you need contravariance) I think it's not worth the effort.

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.