How can I get scalafmt
to format my case class like this?
case class Person(
name: String,
age: Int
) derives Eq, Show
//> using scala "3.3.0-RC1" | |
//> using lib "org.typelevel::cats-effect:3.4.5" | |
//> using plugin "com.github.ghik:::zerowaste:0.2.3" | |
//> using options "-Wunused:imports" | |
//> using options "-Werror" | |
//> using options "-Wvalue-discard" | |
import cats.effect.* | |
object Main extends IOApp.Simple: |
import cats.Show | |
import cats.derived.semiauto.* | |
import cats.syntax.all.* | |
final case class User(name: String, age: Int) derives Show | |
object Demo: | |
@main def run = | |
println(User("Joe", 18).show) // outputs: User(name=Joe, age=18) |
import java.util.UUID | |
import monocle.Iso | |
trait IsUUID[A]: | |
def iso: Iso[UUID, A] | |
object IsUUID: | |
def apply[A](using ev: IsUUID[A]): IsUUID[A] = ev |
I'm going to do something that I don't normally do, which is to say I'm going to talk about comparative benchmarks. In general, I try to confine performance discussion to absolute metrics as much as possible, or comparisons to other well-defined neutral reference points. This is precisely why Cats Effect's readme mentions a comparison to a fixed thread pool, rather doing comparisons with other asynchronous runtimes like Akka or ZIO. Comparisons in general devolve very quickly into emotional marketing.
But, just once, today we're going to talk about the emotional marketing. In particular, we're going to look at Cats Effect 3 and ZIO 2. Now, for context, as of this writing ZIO 2 has released their first milestone; they have not released a final 2.0 version. This implies straight off the bat that we're comparing apples to oranges a bit, since Cats Effect 3 has been out and in production for months. However, there has been a post going around which cites various compar
import com.sksamuel.avro4s.SchemaFor | |
import com.sksamuel.avro4s.refined._ | |
import io.estatico.newtype.Coercible | |
import io.chrisdavenport.fuuid.FUUID | |
import java.util.UUID | |
import scala.concurrent.duration.FiniteDuration | |
import io.circe.{Json, JsonObject} | |
import com.comcast.ip4s.Ipv4Address | |
object avro extends SchemaForCoercible { |
ThisBuild / scalaVersion := "2.13.5" | |
lazy val root = (project in file(".")) | |
.settings( | |
name := "minimal", | |
libraryDependencies ++= Seq( | |
compilerPlugin( | |
"org.typelevel" %% "kind-projector" % "0.11.3" | |
cross CrossVersion.full | |
), |
[Dec16 23:16] [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -2! | |
[ +0.000908] gmc_v9_0_process_interrupt: 24 callbacks suppressed | |
[ +0.000010] amdgpu 0000:04:00.0: amdgpu: [gfxhub0] retry page fault (src_id:0 ring:0 vmid:6 pasid:32769, for process X pid 1073 thread X:cs0 pid 1095) | |
[ +0.000007] amdgpu 0000:04:00.0: amdgpu: in page starting at address 0x00008001018f0000 from client 27 | |
[ +0.000001] amdgpu 0000:04:00.0: amdgpu: VM_L2_PROTECTION_FAULT_STATUS:0x00640C51 | |
[ +0.000001] amdgpu 0000:04:00.0: amdgpu: Faulty UTCL2 client ID: 0x6 | |
[ +0.000001] amdgpu 0000:04:00.0: amdgpu: MORE_FAULTS: 0x1 | |
[ +0.000001] amdgpu 0000:04:00.0: amdgpu: WALKER_ERROR: 0x0 | |
[ +0.000001] amdgpu 0000:04:00.0: amdgpu: PERMISSION_FAULTS: 0x5 | |
[ +0.000001] amdgpu 0000:04:00.0: amdgpu: MAPPING_ERROR: 0x0 |
> dmesg | rg amdgpu | |
[ 0.751743] stage-1-init: [Tue Dec 15 09:27:34 UTC 2020] loading module amdgpu... | |
[ 0.936858] [drm] amdgpu kernel modesetting enabled. | |
[ 0.936959] amdgpu: Topology: Add CPU node | |
[ 0.937028] fb0: switching to amdgpudrmfb from EFI VGA | |
[ 0.937091] amdgpu 0000:04:00.0: vgaarb: deactivate vga console | |
[ 0.937116] amdgpu 0000:04:00.0: enabling device (0006 -> 0007) | |
[ 0.937169] amdgpu 0000:04:00.0: amdgpu: Trusted Memory Zone (TMZ) feature disabled as experimental (default) | |
[ 0.937263] amdgpu: ATOM BIOS: 113-RENOIR-026 | |
[ 0.937324] amdgpu 0000:04:00.0: amdgpu: VRAM: 512M 0x000000F400000000 - 0x000000F41FFFFFFF (512M used) |
implicit def eitherEncoder[A: Encoder, B: Encoder]: Encoder[Either[A, B]] = | |
Encoder[Json].contramap[Either[A, B]](_.asJson) | |
implicit def eitherDecoder[A: Decoder, B: Decoder]: Decoder[Either[A, B]] = | |
Decoder[Json].emap[Either[A, B]] { js => | |
js.as[A] match { | |
case Left(_) => js.as[B].map(_.asRight[A]).leftMap(_.message) | |
case Right(x) => Right(x.asLeft[B]) | |
} | |
} |