Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
swoogles committed Jul 20, 2024
1 parent b93d849 commit 23a34d0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Chapters/04_Initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions Chapters/05_Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```

Expand Down
18 changes: 11 additions & 7 deletions Chapters/06_Failure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 23a34d0

Please sign in to comment.