Road to ZIO(n): chapter 1, the basics

Manuel Rodríguez
2 min readMar 21, 2022

--

Hi!

This is the first article in a series called “Road to ZIO(n)” (pun intended). Here I will depict ho to create a ZIO based HTTP app, just as I like it. It will serve as a wrap-up of many things discussed in this blog, together with the new stuff that I plan to be learning in the weeks to come.

I am pretty excited about this, as for a long time I have been a bit stuck with Scala and this represents a great chance of learning new stuff.

Random guy in the road to ZIO(n). Photo by Joey Nicotra on Unsplash

This is an experiment with ZIO + HTTP4s + DOOBIE. It can be regarded as the continuation of THIS BLOG POST which serves as the inspiration of this project. The full code is stored in THIS GITHUB REPO.

Things that I have changed in this first chapter:

  • repackaging: I have roughly organized the code according to my interpretation of DDD. There is an App Layer, a Domain one, and a Ports one. Also configuration now goes into its own package. This is however an ongoing process.
  • I have introduced typed errors. They look like

This is used around the application. This means that the application will not be based on “Task[U]” but on “IO[Error, U]”, and issues will not be thrown as exceptions but handled functionally as first class citizens. For example,

--

--

Manuel Rodríguez

Developer at New Relic. This is where I keep the cool stuff that I learn in my free time