is ValidatedNel arrow-kt in v1.0 still an Applicative (Functor)?

346 views Asked by At

I understand that in previous versions of Arrow-Kt was an instance of the Applicative typeclass. In the current version 1.0.x, most typeclasses are no longer present/visible (to make the library more accessible, I presume?).

There are some excellent explanations why an error accumulating Validation data type can't be a Monad, for instance Haskell 1 and Haskell 2 and also Scalaz, Cats or arrow-kt. Hoogle also states that

Furthermore, the Monad and Applicative operations should relate as follows:
pure = return
m1 <*> m2 = m1 >>= (x1 -> m2 >>= (x2 -> return (x1 x2)))

My problem is that I can't see an instance of the Applicative Functor instance in the current implementation of Validated in arrow-kt. More precisely, I don't see an ap function anywhere:

(<*>) :: Applicative f => f (a -> b) -> f a -> f b

my intuition tells me that the zip function behaves somewhat similar to a map/ap composition

Haskell/Purescript:

Person <$> validateName first <*> validateName last <*> validateAge age

Kotlin with arrow-kt:

validateName(first).zip(validateName(last), validateAge(age), ::Person)

is zip an ap in disguise? Anything else I might be missing in my reasoning?

1

There are 1 answers

2
nomisRev On BEST ANSWER

Like @LordRaydenMK has already mentioned in a comment zip is ap in disguise to be more in line with the Kotlin Standard Library.

Another strong reason for not having ap in Kotlin is because currying is not 1st class supported by Kotlin as it is in Haskell, and we cannot define multiple parameter lists like in Scala. So far that reason ap is actually quite cumbersome to use, and not user-friendly at all.

So for the sake of user-friendliness, being more idiomatic in Kotlin and decreasing the learning curve Arrow decided to remove ap and offer zip instead.