Replies: 1 comment
-
Further discussions from Slack |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm not sure if this is a known use case on other Functional libs but I was wondering if we could have a way to map (and
flatMap
) a collection to another type. I'm not sure what the name could be as it could be considered a comprehension for limiting the size of a list and doing a fold on that.Something like this could work for Collections:
and then we can use it like:
We can handle any arity thanks to overriding so the caller can decide how many items to look for by the number of parameters on the closure.
For Lists we could also do these for the last items:
And these could also made to fit flatMap.
Our use case for these is as follows:
We have a list of subscriptions for a user and want to check that we have at least one that is active, so we do something like:
Beta Was this translation helpful? Give feedback.
All reactions