---
title: "Discussion on \"Traversing Cats Effect IOs [Part-3]\" | Hashnode"
description: "Discussion on \"Traversing Cats Effect IOs [Part-3]\". 1. Introduction\nThis is the part 3 of the Cats Effect 3 blog series. In the previous two parts, we looked at different ways to create IOs and also some of the common methods that are applied on IOs. Y"
url: "https://hashnode.com/posts/traversing-cats-effect-ios-part-3/62715202d64dcf11c4fb584f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Traversing Cats Effect IOs \[Part-3\]](https://yadukrishnan.live/traversing-cats-effect-ios-part-3?utm_source=hashnode&utm_medium=feed)

1\. Introduction This is the part 3 of the Cats Effect 3 blog series. In the previous two parts, we looked at different ways to create IOs and also some of the common methods that are applied on IOs. Y

May 3, 2022 · 5 min read · yadukrishnan.live  
Updated May 15  
Read the article

-   [#scala](https://hashnode.com/tag/scala)
-   [#thw-web-apps](https://hashnode.com/tag/thw-web-apps)

## Written by

[Yadukrishnan](https://hashnode.com/@yadukrishnan)

@yadukrishnan · Hamburg, Germany

  
[View profile](https://hashnode.com/@yadukrishnan)

Software Developer - Scala

Travel | Movies | History | Nature I am a software developer. Started my career as a Java developer, but later switched to Scala. I wish to write Scala articles which are easier for newbies to follow. I love to travel, prefer to be alone or in very small group. Love to watch movies/series.

## Responses 3

Markdown supported · ⌘↵ to post

[sammo90](https://hashnode.com/@sammo90)

[May 12](https://hashnode.com/posts/traversing-cats-effect-ios-part-3/62715202d64dcf11c4fb584f/comment/6a0315ed937b84f779721e92)

```
extension [A](io: IO[A]) {
  def trace: IO[A] =
    for {
      res <- io
      _ = println(s"[${Thread.currentThread().getName}] " + res)
    } yield res
}
```

Should read:

```
extension [A](io: IO[A])
  def trace: IO[A] = for {
    res <- io
    _   <- IO.println(s"[${Thread.currentThread.getName}] " + res)
  } yield res
```

[sammo90](https://hashnode.com/@sammo90)

[May 12](https://hashnode.com/posts/traversing-cats-effect-ios-part-3/62715202d64dcf11c4fb584f/comment/6a02e240937b84f77943a0b9)

```
def example6 =
  val io1 = IO("Scala6")
  val io2 = IO("Cats6")
  val listTraverse = Traverse[List] // a typeclass instance  -> import cats.implicits.toTraverseOps
  
  val ioList: List[IO[String]] = List(io1, io2)
  val insideOutIOs: IO[List[String]] = listTraverse.sequence(ioList)

  // is equal to the sequence-method:
  // val seqAsTraverse: IO[List[String]] = listTraverse.traverse(ioList)(identity)

  val traversedList: IO[List[String]] = listTraverse.traverse(ioList)(io => io.map(_ + "!"))
  traversedList.trace
```

Due to the import, no typeclass instance is needed anymore!

```
def example7 =
  import cats.implicits.toTraverseOps
    
  val io1 = IO("Scala7")
  val io2 = IO("Cats7")
  
  val ioList: List[IO[String]] = List(io1, io2)
  val insideOutIOs: IO[List[String]] = ioList.sequence

  val traversedList: IO[List[String]] = ioList.traverse(io => io.map(_ + "!"))
  traversedList.trace
```

[Yadukrishnan](https://hashnode.com/@yadukrishnan)

[May 15](https://hashnode.com/posts/traversing-cats-effect-ios-part-3/62715202d64dcf11c4fb584f/comment/6a02e240937b84f77943a0b9#reply-6a0734c873afc887577abba1)

Thanks, i updated the article.
