Hello, are there any examples on `monad-comprehens...
# arrow
f
Hello, are there any examples on
monad-comprehensins
on
StateMonad
? I'm having some code that when implemented with
flatMap
s compiles and run without issues BUT with monad-comprehensions throws
java.lang.NoSuchMethodError: arrow.typeclasses.Monad.getFx()Larrow/typeclasses/MonadFx
So I wanted to check for a reference example
b
Can you post the two different code samples?
f
I'm on 0.10.4. This impl works
Copy code
evalOne("1").flatMap(Id.monad()) {
            evalOne("2").flatMap(Id.monad()) {
                evalOne("+")
            }
        }.runA(Id.monad(), ListK(emptyList())).value()
This impl does not (throws the exception shown in my previous post)
Copy code
val result: State<List<Int>, Option<Int>> = State.fx(Id.monad()) {
            val (_) = evalOne("1")
            val (_) = evalOne("2")
            val (c) = evalOne("+")
            c
        }
        result.runA(Id.monad(), ListK(emptyList())).value()
And this is my function
Copy code
fun evalOne(sym: String): State<List<Int>, Option<Int>> {...}
thanks a lot for any ideas on how to solve this
p
can you please take a look at your
./gradlew dependencies
and see if you're pulling a consistent version or if gradle resolves to a previous one due to a transitive dependency
maybe from KotlinTest
f
thanks, I'm gonna take a look
p
otherwise, try using
.bind()
or
!
instead of destructuring
maybe it's a compiler issue