Whole story: I’m making a talk with introduction t...
# arrow
h
Whole story: I’m making a talk with introduction to functional programming and I want to show people example microservice. On daily basis I’m writing in Scala with Spring, Cats and Doobie, but many people are afraid of Scala, so I’m writing this in Kotlin (which I’m big fan and use it for private projects). I wish I can kind of reflect, using arrow, what we do in Scala code. In repositories we are writing sql by hand using Doobie, which return ConnectionIO and we invoke
.transact
on it to make it
IO
from cats. Example method:
def insertTask(task: ScheduledTask): IO[Either[RepositoryError, Unit]]
Then in facade, we do some logic, invoke repository method and add some more logic and return everything. Facade method is something like:
Copy code
def createTask(
    taskDto: TaskDto,
    username: String
  ): IO[Either[Error, Result.Now[TaskCreationResultDto]]]
And in web controller we return this:
Copy code
facade.createTask(dto, username).unsafeRunSync