Hi. I’m trying to do monad comprehension for `Opt...
# arrow
h
Hi. I’m trying to do monad comprehension for
OptionT
. My stack is
IO<Option<User>>
. I cant figure out what to import to get
OptionT.fx.
I have tried importing arrow.mtl.extensions.fx like described here: https://arrow-kt.io/docs/0.10/arrow/mtl/optiont/, but that doesn’t work
j
M.fx
is usually an explicitly defined extension function for our core datatypes. Not sure why mtl does not define them, but
M.fx
is defined as an alias for
monad().fx.monad {}
anyway, so you can always use that. Fyi: The full definition of the helper is:
Copy code
fun <A> Option.Companion.fx(c: suspend MonadSyntax<ForOption>.() -> A): Option<A> =
  Option.monad().fx.monad(c).fix()
g
Copy code
import arrow.mtl.OptionT
import arrow.mtl.extensions.fx
☝️ 1
j
h
Don’t know what i did wrong before, but that works. Thank you! 🙂
Aha, i imported OptionT from arrow.core.OptionT, but that doesn’t have fx defined. Why is there an OptionT in core and in mtl?
j
There should not be. Maybe you had
Option
instead of
OptionT
?
p
also check that you don't have 2 versions of arrow imported through a 3rd party
h
I had a dependency that used arrow-extras-data:0.9.0. Thank you guys 🙂