When I went through the Example code of Kafka4S, I could not understand what exactly do the multiple colons(:) after F[_] mean. After searching around, re-reading the Scala language spec, I can only guess that this code means that F[_] has the 3 types (Concurrent, ContextShift, Timer) as mixin?
final class StreamProducer[F[_] : Concurrent : ContextShift : Timer] {
val example: F[Unit] =
for {
_ <- Sync[F].delay(println("Starting kafka4s example"))
_ <- AdminApi.createTopicsIdempotent[F](kafkaBootstrapServers, topic)
writeStream = Stream
.resource(ProducerApi.resource[F, Int, Int](BootstrapServers(kafkaBootstrapServers)))
.flatMap { producer =>
Stream
.awakeDelay[F](1.second)
.evalMap { _ =>
Sync[F].delay(Random.nextInt()).flatMap { i =>
producer.sendAndForget(new ProducerRecord(topic.name, i, i))
}
}
}
} yield ()