diff --git a/Chapters/04_Initialization.md b/Chapters/04_Initialization.md index 4ac210fa..74284efe 100644 --- a/Chapters/04_Initialization.md +++ b/Chapters/04_Initialization.md @@ -526,7 +526,8 @@ object OvenSafe: Oven() .withFinalizer: _ => - printLine("Oven: Turning off").orDie + printLine("Oven: Turning off") + .orDie ``` Here, `scoped` produces a `ZLayer` with a finalizer attached to the `Oven` object it provides. @@ -679,7 +680,10 @@ A case class holds configuration information: import zio.* import zio.direct.* -case class RetryConfig(times: Int, msg: String) +case class RetryConfig( + times: Int, + msg: String, +) ``` We can automatically populate `RetryConfig` from a configuration file using the `deriveConfig` macro from the `zio.config.magnolia` module: @@ -735,7 +739,7 @@ def run = .serviceWithZIO[RetryConfig]: retryConfig => val times = retryConfig.times - val msg = retryConfig.msg + val msg = retryConfig.msg println(msg) println(s"Retrying $times times") eatEatEat(retries = times) diff --git a/Chapters/05_Testing.md b/Chapters/05_Testing.md index 21ef6b84..a2360f75 100644 --- a/Chapters/05_Testing.md +++ b/Chapters/05_Testing.md @@ -304,11 +304,13 @@ To artificially provide your own input to the console, use `TestConsole.feedLine val spec = test("Substitute input"): defer: - TestConsole.feedLines("Morty", "Beth").run + TestConsole + .feedLines("Morty", "Beth") + .run val input = readLine.run printLine(input).run val output = TestConsole.output.run - printLine(output).run + printLine(output).run assertTrue(input == "Morty") ``` diff --git a/Chapters/06_Failure.md b/Chapters/06_Failure.md index a8244a4d..5968d1af 100644 --- a/Chapters/06_Failure.md +++ b/Chapters/06_Failure.md @@ -147,7 +147,9 @@ val getTemperature: ZIO[ defer: val maybeScenario = ZIO.config(scenarioConfig).orDie.run - printLine("Getting Temperature").orDie.run + printLine("Getting Temperature") + .orDie + .run maybeScenario match case Some(Scenario.GPSFailure) => @@ -324,13 +326,15 @@ def check(t: Temperature) = defer: printLine("Checking Temperature").run if t.degrees > 0 then - ZIO.succeed: - "Comfortable Temperature" - .run + ZIO + .succeed: + "Comfortable Temperature" + .run else - ZIO.fail: - ClimateFailure("**Too Cold**") - .run + ZIO + .fail: + ClimateFailure("**Too Cold**") + .run ``` ```scala 3 mdoc:runzio