diff --git a/build.sbt b/build.sbt index 44f61ea..2cb6c21 100644 --- a/build.sbt +++ b/build.sbt @@ -17,7 +17,7 @@ lazy val demo = module("demo") .dependsOn(core) .withEfectMonad - .settings(libraryDependencies += "com.htmlism" %% "rufio-zio" % "74-5cd25e9b") + .settings(libraryDependencies += "com.htmlism" %% "rufio-zio" % "76-c565ab28") ThisBuild / resolvers += "mcanlas/rufio" at "https://maven.pkg.github.com/mcanlas/rufio/" diff --git a/data/one-line.txt b/data/one-line.txt deleted file mode 100644 index e3c0674..0000000 --- a/data/one-line.txt +++ /dev/null @@ -1 +0,0 @@ -one line diff --git a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/FeatureDemo.scala b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/FeatureDemo.scala index 57d31b1..7f7d06e 100644 --- a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/FeatureDemo.scala +++ b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/FeatureDemo.scala @@ -8,7 +8,7 @@ import com.htmlism.firepower.core.AsmBlock._ import com.htmlism.firepower.core._ object FeatureDemo: - val program: String = + val program: List[String] = List( CommentBlock.fromMultiline(asciiArt), CommentBlock(List("Change direction: W A S D")), @@ -53,7 +53,6 @@ object FeatureDemo: ) .map(AsmBlock.toLines(AssemblerOptions.InstructionCase.Lowercase)) .pipe(xs => AsmBlock.interFlatMap(xs)(List("", ""), identity)) - .pipe(str.Line.mkString) private lazy val asciiArt = """ ___ _ __ ___ __ ___ 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 8948585..a6a57e5 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 @@ -10,30 +10,20 @@ import zio.* import com.htmlism.firepower.core.AsmBlock._ import com.htmlism.firepower.core.AssemblerOptions._ import com.htmlism.firepower.core._ -import com.htmlism.firepower.demo.str._ import com.htmlism.rufio.withzio.* object PrintPrograms extends ZIOAppDefault: - private def writeLine(file: String)(s: String) = - File(s"data/$file.txt") - .writeLine(s) - private val programs = - List[(String, String)]( - // FEATURE: writing a string to a file is easy (thanks, rufio) - "one-line.txt" -> "one line", - - // FEATURE: writing lines to a file is easy - "two-lines.txt" -> List("foo", "bar") - .pipe(Line.mkString), + List[(String, List[String])]( + // FEATURE: writing lines to a file is easy (thanks, rufio) + "two-lines.txt" -> List("foo", "bar"), // FEATURE: writing paragraphs separated by newlines is easy "two-paragraphs.txt" -> List( List("foo", "bar"), List("alpha", "bravo") ) - .pipe(xxs => AsmBlock.interFlatMap(xxs)(List("", ""), identity)) - .pipe(Line.mkString), + .pipe(xxs => AsmBlock.interFlatMap(xxs)(List("", ""), identity)), "feature-demo.asm" -> FeatureDemo.program, "print-three-upper-math.asm" -> PrintThree.assemble( AssemblerOptions(InstructionCase.Uppercase, DefinitionsMode.UseDefinitionsWithMath) @@ -53,6 +43,6 @@ object PrintPrograms extends ZIOAppDefault: for { // just a traverse in slow motion... _ <- programs - .map { case (f, s) => File(s"data/$f").writeLine(s) } + .map { case (f, xs) => File(s"data/$f").writeLines(xs) } .foldLeft[Task[Unit]](ZIO.unit)((acc, z) => acc *> z) } yield () diff --git a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/PrintThree.scala b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/PrintThree.scala index 559eb1c..eb9dff1 100644 --- a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/PrintThree.scala +++ b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/PrintThree.scala @@ -28,11 +28,10 @@ object PrintThree: val program: List[Move[Easy6502.Color, Easy6502.Screen.Pixel]] = build(Easy6502.Screen(0x200)) - def assemble(opts: AssemblerOptions): String = + def assemble(opts: AssemblerOptions): List[String] = (defines(opts.definitionsMode) ++ codes(opts.definitionsMode)) .map(AsmBlock.toLines(opts.instructionCase)) .pipe(xs => AsmBlock.interFlatMap(xs)(List("", ""), identity)) - .pipe(str.Line.mkString) private def defines(opts: AssemblerOptions.DefinitionsMode) = opts match diff --git a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/SnakeEasy6502.scala b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/SnakeEasy6502.scala index a7bc090..56e9b24 100644 --- a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/SnakeEasy6502.scala +++ b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/SnakeEasy6502.scala @@ -5,8 +5,7 @@ import scala.util.chaining._ import com.htmlism.firepower.core._ object SnakeEasy6502: - def assemble(opts: AssemblerOptions): String = + def assemble(opts: AssemblerOptions): List[String] = (Nil) .map(AsmBlock.toLines(opts.instructionCase)) .pipe(xs => AsmBlock.interFlatMap(xs)(List("", ""), identity)) - .pipe(str.Line.mkString) diff --git a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/str/Line.scala b/firepower-demo/src/main/scala/com/htmlism/firepower/demo/str/Line.scala deleted file mode 100644 index 4b9bafb..0000000 --- a/firepower-demo/src/main/scala/com/htmlism/firepower/demo/str/Line.scala +++ /dev/null @@ -1,6 +0,0 @@ -package com.htmlism.firepower.demo.str - -object Line: - def mkString(xs: List[String]): String = - xs - .mkString("\n")