From 0ed2062e5b84e1bd1ce95764d0f7b089ae5b4850 Mon Sep 17 00:00:00 2001 From: Mark Canlas Date: Mon, 23 Oct 2023 13:56:45 -0400 Subject: [PATCH] remove optional braces --- .scalafmt.conf | 1 + .../com/htmlism/firepower/demo/PrintPrograms.scala | 4 ++-- src/main/scala/com/htmlism/MatchOpcodes.scala | 12 ++++++------ src/main/scala/com/htmlism/ShiftExtractor.scala | 4 ++-- .../com/htmlism/mos6502/model/Instruction.scala | 3 ++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index f2e17a3..20aad94 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -50,3 +50,4 @@ includeNoParensInSelectChains = true optIn.breakChainOnFirstMethodDot = true rewrite.scala3.convertToNewSyntax = true +rewrite.scala3.removeOptionalBraces = true diff --git a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/PrintPrograms.scala b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/PrintPrograms.scala index a2a8f7f..5043b4d 100644 --- a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/PrintPrograms.scala +++ b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/PrintPrograms.scala @@ -37,9 +37,9 @@ object PrintPrograms extends ZIOAppDefault: ) def run: Task[Unit] = - for { + for // just a traverse in slow motion... _ <- programs .map { case (f, xs) => File(s"data/$f").writeLines(xs) } .foldLeft[Task[Unit]](ZIO.unit)((acc, z) => acc *> z) - } yield () + yield () diff --git a/src/main/scala/com/htmlism/MatchOpcodes.scala b/src/main/scala/com/htmlism/MatchOpcodes.scala index 1e594b9..c1ba619 100644 --- a/src/main/scala/com/htmlism/MatchOpcodes.scala +++ b/src/main/scala/com/htmlism/MatchOpcodes.scala @@ -90,10 +90,10 @@ object MatchOpcodes: out.print("") val fancyColumns = - for { + for c <- 0 to 3 b <- 0 to 7 - } yield b * 4 + c + yield b * 4 + c for f <- fancyColumns do out.print(s"${paddedBinary(f, 8)}") @@ -170,11 +170,11 @@ object MatchOpcodes: out.print("") val columns = - for { + for y <- 0 to 1 x <- 0 to 1 z <- 0 to 1 - } yield (z << 2) + (x << 1) + y + yield (z << 2) + (x << 1) + y val rows = 0 to 7 @@ -207,11 +207,11 @@ object MatchOpcodes: out.print("") def wideColumns: Seq[Int] = - for { + for cc <- 0 to 3 y <- 0 to 1 xx <- 0 to 3 - } yield (xx << 3) + (y << 2) + cc + yield (xx << 3) + (y << 2) + cc def wideRows: Seq[Int] = 0 to 7 diff --git a/src/main/scala/com/htmlism/ShiftExtractor.scala b/src/main/scala/com/htmlism/ShiftExtractor.scala index a3baccb..32147e6 100644 --- a/src/main/scala/com/htmlism/ShiftExtractor.scala +++ b/src/main/scala/com/htmlism/ShiftExtractor.scala @@ -20,11 +20,11 @@ trait BitExtractor[A]: def length: Int = self.length + that.length def unapply(n: Int): Option[(A, B)] = - for { + for b <- that.unapply(n) shifted = n >> that.length a <- self.unapply(shifted) - } yield (a, b) + yield (a, b) object AtomExtractor: @tailrec diff --git a/src/main/scala/com/htmlism/mos6502/model/Instruction.scala b/src/main/scala/com/htmlism/mos6502/model/Instruction.scala index 361e136..cac243a 100644 --- a/src/main/scala/com/htmlism/mos6502/model/Instruction.scala +++ b/src/main/scala/com/htmlism/mos6502/model/Instruction.scala @@ -1,6 +1,7 @@ package com.htmlism.mos6502.model -sealed trait Instruction { def theme: String; def color: String } +sealed trait Instruction: + def theme: String; def color: String case object NoInstruction extends Instruction: def theme: String = "noop"; def color: String = "white"