Silly question, is there a concise way to force an expression to have Unit return value? Eg, sometimes the last thing I want to do in an IO block is log something, but Android Log.* methods return integers for some reason not described in the API documentation. I feel silly adding an extra line just for "Unit" to fix the return type.
j
Joram Visser
10/23/2019, 6:48 AM
What about a function that wraps the Android log implementation? Something like
fun log(logger: Logger, level: Level, message: String): IO<Unit> = IO { /* the log impl */; Unit }
.
👍 1
a
aballano
10/23/2019, 9:08 AM
actually logging is a side effect, so you should wrap it with IO as Joram suggested