I
Size: a a a
I
I
I
(
The protocol supports up to 65597 streams with IDs 3-65599. The IDs
0, 1, and 2 are reserved. Value 0 indicates the 2 byte form and an
ID in the range of 64-319 (the second byte + 64). Value 1 indicates
the 3 byte form and an ID in the range of 64-65599 ((the third
byte)*256 + the second byte + 64). Values in the range of 3-63
represent the complete stream ID. Chunk Stream ID with value 2 is
reserved for low-level protocol control messages and commands.
(
I
(
I
implicit class ShowOps[A](val a: A) extends AnyVal {
def show(implicit sh: Show[A]) = sh.show(a)
}
object Show {
def apply[A](implicit sh: Show[A]): Show[A] = sh
def show[A: Show](a: A) = Show[A].show(a)
implicit class ShowOps[A: Show](a: A) {
def show = Show[A].show(a)
}
implicit val intCanShow: Show[Int] =
new Show[Int] {
def show(int: Int): String = s"int $int"
}
}
(
implicit class ShowOps[A](val a: A) extends AnyVal {
def show(implicit sh: Show[A]) = sh.show(a)
}
object Show {
def apply[A](implicit sh: Show[A]): Show[A] = sh
def show[A: Show](a: A) = Show[A].show(a)
implicit class ShowOps[A: Show](a: A) {
def show = Show[A].show(a)
}
implicit val intCanShow: Show[Int] =
new Show[Int] {
def show(int: Int): String = s"int $int"
}
}
(
Show
это тайпкласс, все остальное - утилиткиI
trait Show[A] {
def show(a: A): String
}
I
object Show {
def show[A](a: A)(implicit sh: Show[A]) = sh.show(a)
implicit val intCanShow: Show[Int] =
new Show[Int] {
def show(int: Int): String = s"int $int"
}
}
(
implicit val intCanShow: Show[Int] =
new Show[Int] {
def show(int: Int): String = s"int $int"
}
ShowOps
это имплисит конвершен (ака экстеншен-функция), чтобы через точку вызывать show
у всего, для чего есть реализация тайпкласса(
ShowOps
я хзI
implicit val intCanShow: Show[Int] =
new Show[Int] {
def show(int: Int): String = s"int $int"
}
ShowOps
это имплисит конвершен (ака экстеншен-функция), чтобы через точку вызывать show
у всего, для чего есть реализация тайпкласса(
def mapToStrings[F[_] : Functor, A : Show](as: F[A]): F[String] = ...
(
I
def mapToStrings[F[_] : Functor, A : Show](as: F[A]): F[String] = ...
interface Show<T> {
fun show(a: T): String
}
val intCanShow = object : Show<Int> {
override fun show(a: Int) = "int $a"
}
fun main() {
println(intCanShow.show(1))
}
(
interface Show<T> {
fun show(a: T): String
}
val intCanShow = object : Show<Int> {
override fun show(a: Int) = "int $a"
}
fun main() {
println(intCanShow.show(1))
}
intCanShow
при вызове тебе придется передавать явно(