`traverse` requires applicative of some other kind...
# coroutines
e
traverse
requires applicative of some other kind, which a map is wrapped into, if I understand it correctly So, this will work:
mapK.traverse(Option.applicative()) { Some(it) }
. It will wrap the map in
Option
, so it'll be
Some(mapK)
Now, if
mapK
was
listK
, I would be able to call
sequence
on the result of
traverse
, feeding instance of
ListK
for `Applicative`:
Some(listOf(1, 2, 3)).sequence(ListK.applicative())
The same, unfortunately, doesn't work for
MapK
, for aforementioned problem of lacking applicative instance
d
The kdocs don't seem to correspond though:
Copy code
public abstract fun invokeOnClose(
    handler: (Throwable?) → Unit
): Unit
Registers handler which is synchronously invoked once the channel is closed or receiving side of this channel is cancelled. Only one handler can be attached to the channel during channel's lifetime. Handler is invoked when isClosedForSend starts to return true. If channel is already closed, handler is invoked immediately.
The meaning of cause that is passed to the handler:
- null if channel was closed or cancelled without corresponding argument
- close or cancel cause otherwise.
The handler receives a
Throwable?
... not close or cancel?