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
they will all have different types
and it will work brilliantly
you can then convert strings to objects at the edge (or even build some machinery with witness similarly to how record selection works)
again, if you have A -> B and A -> C, how is that a mapping?
Fabio Labella
@SystemFw
btw I think there might be some confusion about the sort of guarantees that you can provide with static types in a language without full dependent types
it sounds like you want to be able to map the value "a" to the type Boolean and the value "b" to the type Int
this is not directly possible without full dependent types: a value is a runtime entity, whilst a type is a compile time one
the way you simulate it generally is by the pattern of creating singleton types
you create types with exactly one value, provide a type to type mapping, and then need to handle the lifting of values to their singleton types with runtime checks (if they aren't statically known) or macros (if they are)
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
Fabio Labella
@SystemFw
@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: