class Stream[+F[_], +O] extends AnyVal
- A stream producing output of type
O
- May evaluate F effects.
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
# Install Docker CLI and Docker Compose, etc. | |
brew install docker docker-compose docker-credential-helper | |
# Configure Docker CLI. | |
mkdir -p "$HOME/.docker/cli-plugins" | |
ln -sfn '/opt/homebrew/opt/docker-compose/bin/docker-compose' "$HOME/.docker/cli-plugins/docker-compose" | |
echo '{ |
#!/bin/bash -e | |
# Stash the staged files if any. | |
NEEDS_UNSTASH=0 | |
if ! git diff --staged --exit-code >/dev/null; then | |
echo -ne '\033[1;32m' | |
echo -n 'Stashing the staged files' | |
echo -e '\033[0m' | |
git stash | |
NEEDS_UNSTASH=1 |
package armeria.lecture.week3; | |
import java.util.Scanner; | |
import java.util.concurrent.ConcurrentLinkedQueue; | |
import org.reactivestreams.Subscriber; | |
import org.reactivestreams.Subscription; | |
import com.linecorp.armeria.client.WebClient; | |
import com.linecorp.armeria.common.HttpData; |
object Main extends App { | |
// boilerplate | |
import scala.reflect.runtime.universe._ | |
def show[T](value: T)(implicit tag: TypeTag[T]) | |
= tag.toString.replace("Main.", "") | |
// type-level programming |
#!/bin/sh | |
# | |
# NOTE: if you are reading this, probably you should upvote https://github.com/line/armeria/issues/1909 | |
# | |
# get normal zipkin server | |
curl -sSL https://zipkin.io/quickstart.sh | bash -s | |
# Write pom.xml thats responsible for generating armeria-configurator.jar | |
cat << 'EOF' > pom.xml |
import cats.effect.ExitCase._ | |
import cats.effect.Sync | |
import cats.effect.concurrent.Ref | |
import cats.syntax.flatMap._ | |
import cats.syntax.functor._ | |
trait Tap[F[_]] { | |
def apply[A](effect: F[A]): F[A] | |
} |
I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.
This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea
With the recent announcement of cats-effect, a relevant question from the past resurfaces: why does IO
, which is otherwise quite Task
-like, not define both
or race
? To be clear, the type signatures of these functions would be as follows:
object IO {
def both[A, B](ioa: IO[A], iob: IO[B])(implicit EC: ExecutionContext): IO[(A, B)] = ???
def race[A, B](ioa: IO[A], iob: IO[B])(implicit EC: ExecutionContext): IO[Either[A, B]] = ???
}