Skip to content

Instantly share code, notes, and snippets.

import akka.actor.Actor
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy.Stop
import akka.actor.ActorSystem
import akka.actor.Props
import akka.actor.ActorInitializationException
class TestActorParent extends Actor {
override val supervisorStrategy = OneForOneStrategy() {
case a: ActorInitializationException => {
/**
* A simple Java data class with two immutable fields. If I want
* to add a third field (e.g. seconds), I have to update a ton of
* places and remember them all, because a compiler will not tell
* you what you missed. If I generate equals/hashCode/toString, I
* have to remember to do so with every change. And I cannot
* overload constructors and assume default values for parameters,
* because in this class, each field is an int and they'd have the
* same signature, so I have to use the Builder Pattern to do
* default values. This is a maintenance nightmare compared to
scala> import cats._, cats.instances.all._
import cats._
import cats.instances.all._
scala> :paste
// Entering paste mode (ctrl-D to finish)
sealed trait TrafficLight
object TrafficLight {
def red: TrafficLight = Red