Giter VIP home page Giter VIP logo

Comments (7)

milessabin avatar milessabin commented on May 11, 2024

You'll see the same phenomenon with vanilla tagged types, eg.,

scala> import shapeless._
import shapeless._

scala> trait Foo
defined trait Foo

scala> tag[Foo](1)
res0: shapeless.tag.@@[Int,Foo] = 1

scala> tag[Foo](1: Any)
java.lang.ClassCastException: java.lang.Integer cannot be cast to shapeless.tag$Tagged
        at .<init>(<console>:12)
        ...

Is this a showstopper for you, or are you able to make progress by avoiding ascribing Any or AnyRef?

from shapeless.

jonifreeman avatar jonifreeman commented on May 11, 2024

In sqltyped the following query no longer works:

sql("select name, ? as x from person")

Currently it is typed as (Stuff within curlies are records, not structural types. I'm using that syntax just for readability here):

Any => List[{ name: String, x: Any }]

Any, because we do not know anything about x. That's not a deal breaker though. I can drop support for those queries. It is not very common to just send data to database server only to return it back. Perhaps more common is to execute some function in a database like:

sql("select name, upper(?) as x from person")

Typing at least some of SQL queries like that might succeed. Here we at least know that 'upper' returns VARCHAR.

In general, when using records this may cause some unexpected crashes when scalac infers too general type.

def bar(x: Int) = if (x > 10) 5 else "10"

... then in some other source file etc. ....

"foo" ->> bar(2)
java.lang.ClassCastException: java.lang.String cannot be cast to shapeless.record$KeyTag

Now it is not very easy to figure out the cause of the problem. But I guess this is pretty hard to fix, right?

from shapeless.

milessabin avatar milessabin commented on May 11, 2024

I'm afraid so. If you can work around it for now I'll see what I can do for M2.

from shapeless.

jonifreeman avatar jonifreeman commented on May 11, 2024

Yes, no problem. Thanks!

from shapeless.

milessabin avatar milessabin commented on May 11, 2024

Still present in shapeless 2.0.0 and with Scala 2.11.1 ... is this still an issue for you?

from shapeless.

jonifreeman avatar jonifreeman commented on May 11, 2024

It is still an issue but not a critical one. It is a rather rare corner case.

from shapeless.

milessabin avatar milessabin commented on May 11, 2024

Still present in shapeless 2.3.0-SNAPSHOT and with Scala 2.11.7. A fix would most likely involved reverting #20 and that currently breaks records. I'll punt this to 3.0.0.

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.