by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 16:30
    som-snytt commented #9157
  • 16:27
    som-snytt edited #9157
  • 14:07
    scala-jenkins milestoned #9157
  • 14:07
    cahilltr opened #9157
  • 14:04
    bishabosha synchronize #9156
  • 13:45
    bishabosha ready_for_review #9156
  • 13:45
    bishabosha synchronize #9156
  • 13:36
    bishabosha commented #9156
  • 13:35
    OndrejSpanel commented #12106
  • 12:53
    bishabosha commented #9156
  • 12:11
    bishabosha converted_to_draft #9156
  • 07:58
    olafurpg commented #11634
  • 05:38
    eed3si9n edited #8721
  • 02:34
    counter2015 synchronize #9154
  • 02:22
    counter2015 commented #9154
  • 02:20
    counter2015 synchronize #9154
  • 02:08
    counter2015 synchronize #9154
  • 02:07
    som-snytt commented #9154
  • 01:48
    counter2015 commented #9154
  • Aug 06 16:31
    eatkins commented #12097
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 (*, *) -> *
Fabio Labella
@SystemFw
the point is that you can now distinguish, i.e also talk about types of kind
(* -> *) -> *
note the different parentheses
Ichoran
@Ichoran
Here is where symbol soup is not so great unless you're used to it.
Fabio Labella
@SystemFw
* -> * - > * means taking two concrete types
segeljakt
@segeljakt
ok
and if it is nested, or can it be?
Fabio Labella
@SystemFw
(* -> *) -> * means taking one type, which is turn is * -> *, like F[_] in scala
yes it can
you can do whatever you want
that's why it's the best notation :)
it can describe shapes that look pretty weird at first (and there are quite a few of those in more advanced FP)
Ichoran
@Ichoran
It's very sneaky. You don't actually have subtyping, except by talking about kinds you do actually have some types which are more restricted than others.
segeljakt
@segeljakt
Is this valid syntax? F[_[_]]
Fabio Labella
@SystemFw
yes
segeljakt
@segeljakt
is _ existential?
Fabio Labella
@SystemFw
that thing has kind (* -> *) -> *, good job
no