Retrofit integration

Helios has a Retrofit integration adding Helios to the list of available converters.


To start using Helios on a Retrofit project just add the following dependency:



The integration provides an implementation of a Retrofit Converter.Factory called HeliosConverterFactory.

This converter is constructed using the create function which needs a list of the classes and the class Encoder and Decoder.


Let’s look at an example of how to add the Helios’ Retrofit integration.

First of all, we need a model for our example:

data class Person(val name: String, val age: Int) {
  companion object

The @json will automatically generate the Encoder and Decoder for the Person model so we can use it directly on our Retrofit.Builder:

import arrow.core.*
import helios.*
import helios.core.*
import helios.typeclasses.*
import helios.retrofit.HeliosConverterFactory
import helios.retrofit.JsonableEvidence
import retrofit2.Retrofit
fun getRetrofit(): Retrofit = Retrofit.Builder()
    JsonableEvidence(Person::class, Person.encoder(), Person.decoder())

There is also an example project available here.