by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 12 23:09
    mkeskells synchronize #9102
  • Aug 12 22:23
    som-snytt commented #12112
  • Aug 12 22:15
    mkeskells synchronize #9102
  • Aug 12 22:01
    som-snytt commented #9145
  • Aug 12 22:00
    mkeskells synchronize #8970
  • Aug 12 21:25
    mkeskells synchronize #9102
  • Aug 12 20:42
    scala-jenkins milestoned #9166
  • Aug 12 20:42
    regadas opened #9166
  • Aug 12 20:21
    OndrejSpanel commented #12106
  • Aug 12 20:20
    OndrejSpanel commented #12106
  • Aug 12 20:10
    SethTisue milestoned #12113
  • Aug 12 20:10
    SethTisue labeled #12113
  • Aug 12 20:08

    SethTisue on 2.12.x

    remove unused import Merge pull request #9165 from m… (compare)

  • Aug 12 20:08
    SethTisue closed #9165
  • Aug 12 20:08
    SethTisue labeled #9165
  • Aug 12 19:31
    lrytz commented #12106
  • Aug 12 18:14
    Jasper-M commented #12113
  • Aug 12 17:57
    lrytz commented #12106
  • Aug 12 16:35
    tribbloid opened #12113
  • Aug 12 15:21
    mkeskells synchronize #9102
Fabio Labella
@SystemFw
it cannot distinguish between Either[A, B] and Free[F, R] (the F there can be IO, not Int, whereas the A in Either can be IO[Int], or String, but not IO)
that's the explanation I use for kinds
first of all, talking about kinds in Scala is a bit weird, the notation is not great
so I'm going to use Haskell notation, which is std, and show you the translation to scala
basically it starts with types
a type is a compile time label that's attached to a term (a term is a value like 1 or "hello" or map), which can be used to statically prove the absence of certain behaviour
Ichoran
@Ichoran
Haskell notation is basically the optimal notation for talking about types, anyway. It's like someone took that notation and built a programming language around it.
Fabio Labella
@SystemFw
or in layman terms, a type is a way of classifying value (but try to understand the definition above, because that's the correct one)
similarly, there are labels to classify types themselves
these labels are called kinds
segeljakt
@segeljakt
types give values meaning?
Fabio Labella
@SystemFw
that's a cool sentence but it doesn't really mean anything :)
traditionally, a kind system is quite simple
Ichoran
@Ichoran
Types just express what you know about a value (which may or may not not be its actual value) without running the program.
Fabio Labella
@SystemFw
by traditionally I mean in SystemFw, or roughly in Haskell, and it's basically a simply typed lambda calculus at the type level. Which means this
imagine there is no subtyping
like in Haskell
Ichoran
@Ichoran
Kinds are a way to classify your types.
Fabio Labella
@SystemFw
then for some types, you can immediately create values
e.g. if I tell you type Int, you know that 1 is a value
if I tell you String, you know that "hello" is a value
if I tell you Option[Int], you know that None and Some(4) are values
and so on
segeljakt
@segeljakt
ok
Fabio Labella
@SystemFw
the types you can create values for immediately are said to have kind * (pronounced star or Type)
but what about the type Option
you can't create a value of type Option, option of what?
you need further information
if I tell you Option[Int] , then you know
so the type Option needs to know about another type
so Option is said to have kind * -> *
which you can read as a function at the type level
Option has kind * -> * because it takes a concrete type (i.e. a type of kind *, e.g. Int), and returns another concrete type (i.e. a type of kind *, i.e. Option[Int])
does that make any sense at all?
segeljakt
@segeljakt
yeah
a * -> * is like a function taking a type as an argument and returning a type?
Fabio Labella
@SystemFw
yep
Ichoran
@Ichoran
The notation is perhaps overly abstract.
Fabio Labella
@SystemFw
you can also read that as
Type -> Type
might make it a bit easier, I'm just used to * by now
segeljakt
@segeljakt
How do you write it if it is Either[Int,Float]
Ichoran
@Ichoran
It's the symbol soup problem, really. Using arrows to define functions is cool when there's only one, but it gets perplexing when you have a bunch of them.
Fabio Labella
@SystemFw
now in Haskell all functions are curried, so (a, b) -> c is represented as a -> (b -> c) and -> is right associative, so you can write a -> b -> c
and the same is true of types
Ichoran
@Ichoran
@klassegeljakt - Well, two types go in, and one goes out, so what would you guess?
Fabio Labella
@SystemFw
so the kind of Either is * -> * -> *
spoiled that, sorry :)
segeljakt
@segeljakt
ah ok
Ichoran
@Ichoran
Which is the curried version of (*, *) -> *