droste
droste copied to clipboard
Add find operation to FoldableOps
This adds the find
operation to FoldableOps
, to match the first element of the structure for which the partial function passed as argument is defined.
I'm not sure if this is the correct semantic of find
operation for a given R
recursive type. I have another implementation taking a boolean predicate like any
, or all
operations do, but then the result type of find
changes from Option[B]
to Option[R]
, returning the whole substructure from where the first match succeeded.
I also had to add a new tag First
and the Option
monoid in order to use foldMap
. Another concern is that I don't know if this shortcircuits on the first match (does any
operation shortcircuit?).
Any feedback is more than welcome, as this is my first time working with recursion schemes concepts.