Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
State
to allow to be called infix
get[Int].map..
etc
def map[A, B]: State[S, A] => (A => B) => State[S, B]
State[S, B]
State[S, B]
? at this point the only thing we have that type checks, it's the constructor
how do we create a
State[S, B]
? at this point the only thing we have that type checks, it's the constructor
so that's where we got to
S => (S, B)
def map[A, B](fa: State[S, A])(f: A => B) : State[S, B] = State[S, B] { s: S =>
// more work to do here
def result: (S, B) = ???
result
}
val a = get[Int].map(_ + 1).map(_.toString)
a.run(3)._1 // "4"
a.run(7)._1 // "8"
State
in its entirety yet (pure
, flatMap
, put
, modify
etc)
run
function"