Closed TheWix closed 12 months ago
Hey, can you share some examples?
Sorry @gigobyte , just seeing this. Here's a simple example:
declare const div: (a: number) => (b: number) => Either<string, number>
declare const a: Either<string, number>
declare const b: Either<string, number>
const res = b.ap(a.map(div))
This makes sense to me. We have map
for functions that don't return effects, and chain
(composition of map
and join
), but I haven't found anything similar for applicatives. I even asked on the functional programming slack and got no answer. I also haven't seen an equivalent in fp-ts. I feel like I am missing something...
Yeah I don't think there's a function for what you're trying to do and my FP is getting rusty so I can't think of anything clever with the existing methods.
Yea, the only thing I can think of is adding a function apChain
that is similar to just chain
where it is just ap
followed by join
.
This is an interesting one and I haven't seen such a function elsewhere, but how would one handle using
ap()
with a function that returns an effect? I am finding myself constantly callingjoin
because I am composingEither
with functions that also returnEither
? Is something likeapChain
a thing? Or am I doing something wrong?