Hi! I'm starting to use arrow for data validation ...
# arrow
d
Hi! I'm starting to use arrow for data validation (I'm not super familiar with the library, but I used cats/scalaz libraries for scala in the past). Following the docs about Validated I noticed that this snippet doesn't compile
Copy code
data class Config(val map: Map<String, String>) {
  suspend fun <A> parse(read: Read<A>, key: String) = either<ConfigError, A> {
    val value = Validated.fromNullable(map[key]) {
      ConfigError.MissingConfig(key)
    }.bind()
    val readVal = Validated.fromNullable(read.read(value)) {
      ConfigError.ParseConfig(key)
    }.bind()
    readVal
  }
In particular I wasn't able to call
bind()
from a
Validated
. Is that something I am missing? Also I noticed that
bind()
is not listed among the functions for
Validated
in the docs. I'm using
arrow-core version 0.11.0
c
This compiles fine for me, what error are you receiving?
👍 1
bind is part of the EitherEffect interface, it’s part of the
this
context inside the either { } lambda
d
Thanks for the help. Here for example (sorry for the bad formatting): val value = Validated.fromNullable(map[key]) { ConfigError.MissingConfig(key) }.bind() The IDE is complaining that it can't find the function "bind()". But If I write val value = Validated.fromNullable(map[key]) { ConfigError.MissingConfig(key) } .toEither() .bind() It compiles. Even if this val are declared locally inside the lambda Validated .fromNullable(map[key]){ ConfigError.MissingConfig(key) } is of type Validated, not Either. Hence my confusion...