Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 25, 2024 10:20
Show Gist options
  • Save dacr/1d407339f8f5fb214da0d703a73d0d52 to your computer and use it in GitHub Desktop.
Save dacr/1d407339f8f5fb214da0d703a73d0d52 to your computer and use it in GitHub Desktop.
ZIO learning - zio aspects / published by https://github.com/dacr/code-examples-manager #ca811a16-7fe8-4290-9243-bc41fe58351a/b823fc9948dc64294c0a6f32f9f55c387d2bbd1d
// summary : ZIO learning - zio aspects
// keywords : scala, scalacli, zio, aspect, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : ca811a16-7fe8-4290-9243-bc41fe58351a
// created-on : 2021-11-14T08:36:25+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.4.2"
//> using dep "dev.zio::zio:2.0.13"
// ---------------------
import zio.*
object Encapsulated extends ZIOAppDefault {
def run = for {
result1 <- ZIO.attempt(42) @@ ZIOAspect.logged("op1")
result2 <- ZIO.succeed("oups") @@ ZIOAspect.logged("op2")
} yield (result1, result2)
}
Encapsulated.main(Array.empty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment