Hi!! I’m playing around with Kleisli but I don’t u...
# arrow
n
Hi!! I’m playing around with Kleisli but I don’t understand how to use
map2
with the two Kleisli instances I’ve created,
readNameKCO
and
readAgeKCO
. My goal is to create a new Kleisli that generates a
Person
instance from a
Config
one and then using it with
personK.run(config)
. I’m doing something wrong for sure but I don’t quite understand out to build the
personK
Kleisli
j
It would be helpful to see the complete code.
j
map2
's signature is:
Kind<F, A>.map2(fb: Kind<F, B>, f: (A, B) -> C): Kind<F, C>
. This means it is not related to tuples directly. Instead you should use it as
readNameKCO.map2(readAgeKCO) { (name, age) -> ... }
There is also
mapN
which is a little nicer:
mapN(readNameKCO, readAgeKCO) { (name, age) -> ... }
n
thank you very much. I wasn’t that far from the correct way 🙂
👍 1