Hi. I've noticed that with functions returning `Un...
# arrow
a
Hi. I've noticed that with functions returning
Unit
, monad comprehensions can lead to a somewhat confusing behaviour:
Copy code
g(): TUnit = TODO()
f() = fx { g() }
f0() = fx { g().bind() }
Both
f
and
f0
return
TUnit
for any given
T
, but have different semantics. Is there any way, apart from introducing my own
MyUnit
object
that I can guard against accidental omission of
.bind()
?
t
In this example
f()
returns a
F<F<Unit>>
. So you can use
flatten
after your
fx
block to return
F<Unit>
and this will work as well
a
@Tesserakt yes, I think I was mistaken in my initial assumption. Thanks!
👍 1