Hi all, I'm trying to map my storage API to my dom...
# arrow
i
Hi all, I'm trying to map my storage API to my domain layer, but I'm struggling pulling it off. My idea is having a
Copy code
fun <T> load(key: String): IO<NoValueFoundForKey, T> {...}
on the lower layer and then mapping it to a higher layer with something like this:
Copy code
override fun areRemindersEnabled(): IO<Nothing, Boolean> {
        val storedReminderSettings: IO<NoValueFoundForKey, Boolean> = storage.load(key)
        return storedReminderSettings
            .map { areEnabled -> IO.just(areEnabled) }
            .handleErrorWith { IO.just(false) }
    }
I'm thinking of
fun areRemindersEnabled(): IO<Nothing, Boolean>
because I would like to take care of the possible errors and allow consumers to just get a
Boolean
in every situation. I thought I could pass through the boolean if everything is fine and handle the error and propagate a boolean if things go south. At the moment I'm stuck because types don't match. I'm not confident on the syntax or the whole approach either. I'm experimenting here to be able to understand how to use
IO
and proposing it effectively to my teams. Any pointer, please?