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?
Like @LordRaydenMK has already mentioned in a comment
zip
isap
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 reasonap
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 offerzip
instead.