Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 27 16:43

    joroKr21 on main

    Update slf4j-nop to 2.0.5 (#129… (compare)

  • Nov 27 16:43
    joroKr21 closed #1293
  • Nov 26 17:38
    scala-steward opened #1293
  • Nov 24 22:35

    joroKr21 on main

    Update sbt-scalajs, scalajs-com… (compare)

  • Nov 24 22:35
    joroKr21 closed #1291
  • Nov 24 22:14
    joroKr21 synchronize #1291
  • Nov 24 22:13
    joroKr21 closed #1288
  • Nov 24 22:13

    joroKr21 on main

    Update junit-plugin, junit-runt… (compare)

  • Nov 24 22:13
    joroKr21 closed #1292
  • Nov 24 18:03
    scala-steward commented #1288
  • Nov 24 18:03
    scala-steward opened #1292
  • Nov 24 18:03
    scala-steward opened #1291
  • Nov 19 21:17

    joroKr21 on main

    Update slf4j-nop to 2.0.4 (#129… (compare)

  • Nov 19 21:17
    joroKr21 closed #1290
  • Nov 18 20:54
    scala-steward opened #1290
  • Nov 15 06:50
    joroKr21 commented #1286
  • Nov 15 06:48
    joroKr21 commented #1287
  • Nov 15 06:41
    joroKr21 synchronize #1288
  • Nov 15 06:41

    joroKr21 on main

    Update sbt to 1.8.0 (#1289) (compare)

  • Nov 15 06:41
    joroKr21 closed #1289
Fabio Labella
@SystemFw
the pattern I mention above with objects as key + HMap does exactly that
and the same pattern is used by shapeless labelled generic, without going through objects but directly exposing the singleton types of strings through macro magic
@rquinlivan
Tim Spence
@TimWSpence

If I have a recursively-resolved typeclass like this:

trait Foo[A] {
  type Repr
  def to: Repr
}

With at most one instance for a given A. Is there a way to write an instance summoner that looks something like this:

def instance[A](implicit foo: Foo.Aux[A,R]): R = ???

? And if so, will the compiler correctly infer the concrete type rather than some Foo.Aux… type?

Fabio Labella
@SystemFw
def instance[A](implicit foo: Foo[A]): foo.Repr = foo
Tim Spence
@TimWSpence
sigh, that was surprisingly obvious! :joy:
Will the compiler infer the concrete type of Foo[A].repr for a given A?
Fabio Labella
@SystemFw
if you've declared things right, yes
Tim Spence
@TimWSpence
:joy: we’ll find out
Thanks Fabio!
Fabio Labella
@SystemFw
:+1: :)
Tim Spence
@TimWSpence
@SystemFw it didn’t work :sob: Any suggestions off the top of your head or shall I try to dump the code in a gist somewhere?
Fabio Labella
@SystemFw
make sure you have an explicit type for your instances, which is Auxed
e.g implicit def yo: Foo.Aux[A, Int]
implicit def yo: Foo[A] won't work (that's what I meant by declaring things right)
if that fails, a small reproducible gist will do
and that means you have a logical error in your derivation somewhere
Tim Spence
@TimWSpence
Oh that could be it! My instances are just typed Foo[String] etc
Fabio Labella
@SystemFw
yeah, you are losing your refinements
a very simple way to fix it is to remove the type sigs
however , that can hit some weird corner cases
so explicit types with Aux is the best practice
Tim Spence
@TimWSpence
Are implicits with no explicit type annotation eligible for this stuff? I thought they weren’t valid as implicit arguments
Fabio Labella
@SystemFw
they are eligible and valid
the inferred type will infer the refinement
the problem is that you hit some bugs sometimes (pretty weird ones)
probably dotty will require explicit signatures for implicits though
Tim Spence
@TimWSpence
Cool, thanks!
Miles Sabin
@milessabin
Aux is the way to go.
It's still needed in Dotty I'm afraid.
It would be good to come up with a way to avoid it.
Fabio Labella
@SystemFw
I'm actually worried about how obscure things will be with the new given syntax and so on
we don't need Aux as much though, right? if parameters can depend on each other within lists
Miles Sabin
@milessabin
There's that. But the other use of Aux to abbreviate duplicated type member declarations in result types doesn't go away.
Fabio Labella
@SystemFw
yeah that makes sense
however perhaps you can just write the full refinement in that case, it's not that big of a deal if only the return type is affected. I think what confuses people about Aux is the prolog style it forces when thinking about your type params, mostly
and that is fixed if you can do (implicit gen: Generic[A], foo: Foo[gen.Repr])
although again, I wonder how that works with the new syntax
Tim Spence
@TimWSpence
Thanks @SystemFw and @milessabin - it (finally) worked! :)
Miles Sabin
@milessabin

although again, I wonder how that works with the new syntax

I'd need to check, but I'm pretty sure it works in much the same way.

Fabio Labella
@SystemFw
:+1:
Ben Kyrlach
@bkyrlach

With the help of the kind folks on here, I finally got some code that works. If anyone was extremely bored and wanted to provide some feedback, I'm sure there's plenty of improvements that could be made.

https://gist.github.com/bkyrlach/cf8ea12ded3c6fb07c14d9c00b33a818
https://gist.github.com/bkyrlach/2ba7fcad87e780e9958c34f898beb468

PhillHenry
@PhillHenry

I suspect this is a silly question: it appears that the values given to create a shapeless.Sized need to be explicitly typed in by the programmer. Is there any way to make this more flexible - perhaps with values pulled from a more dynamic source...?

I'm guessing the answer is 'no' but since Shapeless does things I never thought would be possible, it's worth asking the question.

Fabio Labella
@SystemFw
the answer is no
well, maybe you can read from a file during a macro or something, but basically it needs to be known statically when you compile
this is a general point with what Scala can and cannot do: when you build a typed model, all you can do is then dynamically check if something adheres to that model, but not infer the model dynamically
example, let's say you build a typed schema with shapeless. Most of your code will have compile time guarantees about it
at the edge of your code you can say "I dynamically assert that this piece of data conforms to this schema, and will throw an error otherwise"
PhillHenry
@PhillHenry
I thought not. Thanks @SystemFw
Fabio Labella
@SystemFw

:point_up: March 6, 2019 4:26 PM

it's somewhat related to this point