Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 18:28
    pjfanning commented #12327
  • 18:28
    robert-blankenship commented #12327
  • 18:27
    robert-blankenship commented #12327
  • 18:25
    robert-blankenship commented #12327
  • 17:34
    som-snytt commented #11631
  • 15:28

    SethTisue on 2.13.x

    advance http4s to make it green… (compare)

  • 14:11
    SethTisue commented on cf1b35b
  • 14:10

    SethTisue on 2.13.x

    avro4s went green on JDK 17 (compare)

  • 08:29
    scala-jenkins milestoned #9768
  • 08:06
    NthPortal edited #9768
  • 08:04
    NthPortal labeled #9768
  • 08:04
    NthPortal opened #9768
  • 08:04
    NthPortal labeled #9768
  • 07:46
    nwk37011 synchronize #9752
  • 07:12
    xuwei-k commented on cf1b35b
  • 06:17
    som-snytt commented #12464
  • 05:59
    NthPortal commented #9275
  • 05:45
    NthPortal commented #9388
  • 05:44
    NthPortal commented #12464
  • 05:38
    NthPortal synchronize #9388
Fabio Labella
@SystemFw
matter of fact
encoding existentials through universals in a simple way requires higher rank polymorphism (which I've talked about in this channel a few days ago), which scala doesn't have
Vinayak Pathak
@vinayakpathak
i see
Fabio Labella
@SystemFw
you could simulate it in this case, but then again abstract types already give you a way of encoding existential quantification, so...
Vinayak Pathak
@vinayakpathak
i'm thinking about your statement: "I have a Monoid for some type, but I dont know which type"
Fabio Labella
@SystemFw
yeah, that doesn't hold
go back to Model
you have a Model for some State, but you don't know which State
hence when you try to coerce it to Int, type mismatch
Vinayak Pathak
@vinayakpathak
that is if I write val m: Model = new Model {...}?
Fabio Labella
@SystemFw
yes
Vinayak Pathak
@vinayakpathak
i see i see
so existential types allow us to define values that have this information hiding feature
if you wanted to define a function that took a Model without knowing its State, you could do that with universal types too no?
Fabio Labella
@SystemFw
nope
Vinayak Pathak
@vinayakpathak
def f[Model[_]] = ??? ?
Fabio Labella
@SystemFw
because you would have Model[State]
wait
the _ you are using there doesn't mean what you think it means
because scala is weird
like
I know what you mean
but your code there doesn't mean that
Vinayak Pathak
@vinayakpathak
i see!
Fabio Labella
@SystemFw
it means that you are taking a higher-kinded type Model[_]
or in other words
def f[Model[_]] = ???
is not the same
and in fact has nothing to do with
def f(model: Model[_]) = ???
this is what you mean
a wildcard type
which again, it's a feature that encodes existentials
Vinayak Pathak
@vinayakpathak
actually yes, that's what i meant indeed
isn't this saying that f takes a value of type Model but doesn't care what State is
Fabio Labella
@SystemFw
yes
it's introducing an existential again
which is clearer if you use the forSome thing (which however is going away)
def f(model: Model[A] forSome { type A })
Vinayak Pathak
@vinayakpathak
i see i see
Fabio Labella
@SystemFw
whereas def f[A](model: Model[A]) means forall type A
Vinayak Pathak
@vinayakpathak
right
ok so doesn't it then encode existential types?
Fabio Labella
@SystemFw
what's "it" now?
Vinayak Pathak
@vinayakpathak
umm def f(model: Model[_])
or the one using forSome
Fabio Labella
@SystemFw
yes it does
both do
but thats' because you are using specific features that introduce existentials
you are not using universals anymore