Created
January 2, 2017 13:23
-
-
Save sighingnow/1fccd56ffc963a11d68b668c1bd53daa to your computer and use it in GitHub Desktop.
concatMap and filter using Foldable and Traversable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concatMap :: (Foldable f, Monoid (f b)) => (a -> f b) -> f a -> f b | |
concatMap = foldMap | |
filter :: (Applicative f, Foldable f, Monoid (f a)) => | |
(a -> Bool) -> f a -> f a | |
filter p = foldMap (\a -> if p a then pure a else mempty) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment