How best to call multiple functions on one value? #1615
Unanswered
edalex-ian
asked this question in
Q&A
Replies: 2 comments 6 replies
-
If they're all endomorphisms ( const applyEvery = <A>(fs: Array<Endomorphism<A>>): Endomorphism<A> => (x) =>
pipe(
fs,
A.reduce(x, (y, f) => f(y)),
)
pipe(x, applyEvery([f, g, h])) == pipe(x, f, g, h) |
Beta Was this translation helpful? Give feedback.
4 replies
-
Based on your example, could try pipe(
aNullableString,
O.fromNullable,
O.map(A.flap),
O.flap(actions),
); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Again,
I'm trying to understand what is the correct way to call multiple functions against one value in a pointfree fashion.
But let me try and provide a somewhat abstract example:
But I'd prefer if that list of functions were in an array. To do that I've ended up with something like:
However the
X.of
,X.ap
andapply
makes me wonder if there's not a better way. (Especially when in reverse - if I had an array of values and then a single function I've done things likeA.traverse(IO.Applicative)
etc.)Thanks for reading, I appreciate any guidance you can offer. 😁
Beta Was this translation helpful? Give feedback.
All reactions