Question
Using foldMap, define a generic version of the higherorder function filter on lists that can be used with any foldable type:filterF :: Foldable t => (a -> Bool) -> t a ->[a]Solutions to exercises 1 and 2 are given in appendix A.
Step 1
We need to define a function `filterF` that takes two arguments: a predicate function `p` of type `(a -> Bool)` and a foldable container `t a`. Show more…
Show all steps
Your feedback will help us improve your experience
Watch the video solution with this free unlock.
EMAIL
PASSWORD