When using `bind` inside `either { ... }` I’m gett...
# arrow
j
When using
bind
inside
either { ... }
I’m getting this message
‘bind(): A’ is deprecated. This object introduces dangerous behavior.
What am I suppose to use now? I see there is
ensure
but I don’t really understand how to use it properly
m
Perhaps something like this @jean?
which version of arrow are you using in there?
r
s
I suspect you have an old import to
arrow.core.continuations.result.bind
or something like that. I think you're trying to bind
Either<Throwable, A>
within
either<E, A>
where
E != Throwable
this was an old issue with a visibility issue. So I think it's missing a
mapLeft
somewhere after a
Either.catch
. Is that possible?
j
I use version 1.2.0-RC I had this import
import arrow.core.computations.ResultEffect.bind
where it was saying “‘ResultEffect’ is deprecated. ResultEffect is replaced with arrow.core.raise.ResultRaise” and the IDE suggested to replace
ResultEffect
with
ResultRaise
. But that gave me a “Cannot import ‘bind’, functions and properties can be imported only from packages or objects”
I notice that if I replace my left type (which is a sealed class) with
Throwable
I don’t get the bind deprecation error anymore
m
ahh.. then it’s likely what Simon mentioned @jean, maybe try wrapping it with
either { }
? should be the one from
arrow.core.raise.either
as Raul mentioned. The bind extension function will appear within the context scope.
Copy code
either {
  myDataFactory().bind()
}
j
Yes, I needed to add a
mapLeft
after my
either
, thanks for the help!
s
Yes, I think so. Somewhere there is a conversion from
Throwable -> E
missing using
mapLeft
to your sealed class. It was unsafe behavior that leaked into
1.0.0
IIRC, and was deprecated in
1.1.x
and marked as
ERROR
in
1.2.x
IIRC
969 Views